Bit operations, base64

I have 4 bytes with 6 significant bits (base64) which should be concatenated into 3 bytes, moved to the left.
Im just wondering if this is right, or maybe if theres some better solution:
oldbyte1 << 2;
tempbyte2 = oldbyte2;
tempbyte2 >> 4;
newbyte1 = oldbyte1 | tempbyte2;
oldbyte2 << 4;
tempbyte3 = oldbyte3;
tempbyte3 >> 2;
newbyte2 = oldbyte2 | tempbyte3;
oldbyte3 << 6;
newbyte3 = oldbyte3 | oldbyte4;Stig.

Studenik:
This is part of a decoding algorithm for Base-64 encoded content (RFC 1421). This encoding technique allows a binary file or message to be transmitted through applications or protocols that traditionally only work with human-readable data, such as News or Mail.
Each group of 3 8-bit byte values, 24 bits, are split into a group of 4 6-bit values. Each of these values (0-63) is then mapped to a printable ASCII character [A-Z,a-z,0-9,+,/]. The process is reversed to recover the original binary values.
Slackman:
Except for a few syntax errors, it looks "right". You need to turn those bit shift operators into bit-shift assignments, and the results of your bitwise OR needs to be cast back to byte (the OR implicitly promotes both values to ints): tempbyte3 >>= 2;
newbyte2 = (byte)(oldbyte2 | tempbyte3);
oldbyte3 <<= 6; I typically have used an algorithm that first recombines the 6-bit values back into a 24-bit int and then splits them back into 8-bit values. I found that it works well when I'm passing the byte values into a method by array and want to avoid modifying the values:     /**
     * decodes a group of 4 base-64 digital values, stored as
     * individual bytes, into 3 base-256 digital values.
     * @param src       input bytes
     * @param srcOffset index of the first byte to decode in src
     * @param dst       output bytes
     * @param dstOffset where in dst to start writing bytes to
     * @return the 3 output bytes rendered as a single int
    static public int decodeBase64(byte[] src, int srcOffset, byte[] dst, int dstOffset) {
        int retval ;
        int register = src[srcOffset] ;
        int i ;
        for (i=1; i<4; i++) {
            register = (register << 6) | src[srcOffset + i] ;
        retval = register ;
        for (i=2; i >= 0; i--) {
            dst[dstOffset + i] = (byte)register ;
            register >>>= 8 ;
        return retval ;
    }I've found that your algorithm works well with individual bytes.

Similar Messages

  • How can I install after effects on 32 bit operating system?

    How can I install after effects on 32 bit operating system?
    I cant even find it in creative cloud.
    I want to make  a intro but it dossent allow me to even find/ istall it.
    I hope some one will help me by anwsering my question.
    Than you for time.

    If your system does not meet the minimum system requirements you have to go back to a version that does. Try the direct download links you'll find here.. CS5 comes bundled with CS4 for AE which is the last  version to run on a 32 bit system.

  • New iTunes still not working with 64 bit operating systems?

    When will iTunes support advanced 64 bit operating systems...
    Would seem that a next generation phone would work with the next generation of operating systems...

    iTunes does work with vista 64 bit. I can sync my iPod with it. It's the 'Apple Mobile Device Support' portion that is required by the iPhone that isn't working.

  • HP business inkjet 2800 Print black only option not showing in Windows 7 64 bit operating system

    HP business inkjet 2800 Print black only option not showing in Windows 7 64 bit operating system
    Please help, if any one knows any solution.

    Hi @Firoskhan,
    Welcome to the HP Forums!
    I am sorry, but to get your issue more exposure I would suggest posting it, in the commercial forums since this is a commercial product. You can do this at HP Enterprise Business Community.
    Hope this helps!  
    RnRMusicMan
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" to say “Thanks” for helping!

  • HP Laserjet p2015d auto duplex printing with Windows 7 64 bit operating system

    I have used the HP Laserjet p2015d with Windows 7 32 bit operating system and have been able to use the AUTOMATIC DUPLEX feature of the printer without problems.
    Now, however, I have installed the 64 bit version of Windows 7 operating system and the AUTO DUPLEX does not work and is not shown as being available on the PROPERTIES menu of the printer.
    Is it possible to use the AUTO DUPLEX  feature of  the printer with Windows 7   64 bit  operating system.
    All replies welcomed!   Aaron in Calif.

    Hi Aaron,
    Make sure the Automatic Duplexing option is enabled:
    Enter Control Panel > Devices and Printers.
    Right click the printer icon, then click Printer Properties.
    Click the Device Settings tab.
    Set the Automatic Two-Sided Duplex Accessory as installed and click OK to save the change.
    Now Automatic Duplexing should become available.
    Regards,
    Shlomi
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • Ram utilization with 64 bit operating system

    Attached is the current configuration of my 8.1 Pro PC & I have a question regarding RAM utilization with 32 bit programs running on this PC.
    It has been my understanding that the 32 bit OS (XP Pro), at best, would be able to only utilize 4GB of RAM memory.  
    I've recently built a PC for the specific task of running an application which is very CPU & output intensive. The application is a Windows based 32 bit application which analyzes and recovers data from NAND chips.  Input data comes from a 2.0 USB
    feed, is processed and is then written to a 2 disk raid array.
    Will the 64 bit operating system enable 32 bit applications to utilize more than 4GB of RAM memory?  Any suggestions on how to maximize the processing of 32 bit application on a 64 bit OS would be appreciated.
    Operating System
    Windows 8.1 Pro 64-bit
    CPU
    Intel Xeon E3 1275 v2 @ 3.50GHz
    35 °C
    Ivy Bridge 22nm Technology
    RAM
    16.0GB Dual-Channel DDR3 @ 657MHz (9-9-9-24)
    Motherboard
    Supermicro X9SAE (CPU)
    37 °C
    Graphics
    HP w2408 (1920x1200@59Hz)
    Intel HD Graphics (Super Micro Computer)
    Storage
    372GB Western Digital WDC WD4000AAKS-00TMA0 (SATA)
    30 °C
    465GB Western Digital WDC WD5000HHTZ-04N21V0 (SATA)
    28 °C
    465GB Western Digital WDC WD5001ABYS-01YNA0 (SATA)
    32 °C
    465GB Western Digital WDC WD5003ABYX-01WERA1 (SATA)
    31 °C
    Optical Drives
    PLEXTOR DVDR PX-891SAW
    TSSTcorp CDDVDW SH-224DB
    Audio
    High Definition Audio Device

    Hi,
    As far as I know, 32-bit application running on x64 Windows system had a limit of memory address space. The max usage of RAM is 4GB. I also make a test using testlimit:
    According to the screenshot, we can find that, 32-bit testlimit only can leak 4051MB memory, while 64bit testlimit can achieve to 5200 even more larger memory.
    For more information about this knowledge, you can refer to contents of chapter 9 in Windows Internal:
    http://live.sysinternals.com/WindowsInternals/WindowsInternals-Ch05.pdf
    Roger Lu
    TechNet Community Support

  • Can you tell me if I have a 64 bit operating system which Java update do I download

    Please can anyone advise me on what Java update I download for a Windows 7 64 bit operating system. My Firefox is telling me I need to urgently update my Java but when I click through to update all that is there is a page of confusing information about 32 bit and 64 bit systems. It asks which version am I using 64 bit version of Firefox or 32 bit. I didn't know there were two, I thought when referring to 64 bit and 32 bit it meant the operating system of my computer. Can anyone clear this up for me. Thank you.

    Of course, if you have a x64 bit system, its better to download a x64 bit Java version. However, i think Firefox won't be able to use it since Firefox isn't x64 bit (yet). So if you need Java in your browser, you'll need Java's 32bit version.
    Keep in mind i could be wrong. It's just my guessing because i tried it out some months ago. I installed 64bit Java but Firefox couldn't handle it.
    However in my opinion you won't recognize a difference between 32 and 64 bit, unless you play games in Java or do other resource intensive work. 32bit will always work on a 64bit PC, but not the other way around.

  • Hi everyone.. I have windows 7 (32 bit operating system), and have tried installing the latest version of Itunes, but my PC keeps saying windows 7 error (126) ? I have no idea on how to fix this??

    hi everyone.. I have windows 7 (32 bit operating system), and have tried installing the latest version of Itunes, but my PC keeps saying windows 7 error (126) ? I have no idea on how to fix this??
    Please could someone help???
    And it also mentions mediatoolbox dll. is missing?? haha i have no idea what that means??? please help...
    Thanks alot! I really appreciate your help..

    Try the following user tip:
    Troubleshooting issues with iTunes for Windows updates

  • HT2305 I have Widows 8 but my Itunes wont open I keep getting a message "Itunes software does not install on 64 bit operating system"

    I have a Widows 8 laptop. I cant open Itunes. I get a message "Itunes software does not install on 64 bit operating system" Can anyone tell me how to get it installed?

    If you are referring to Vista Support, It may be after the new year before it fully supports vista. I have not upgraded to vista yet but I was thinking about it!

  • [SOLVED]Can I run a 64 bit operating system?

    I want to know if I can run a 64 bit operating system on my laptop. the lshw command says I have a 64 bit processor, so does that mean I can run a 64 bit O.S. because  almost everything else says 32 bit. So, does all my hardware have to be 64 bit, or is it only the processor that matters? I have looked on the internet and it always seems to relate only to the processor, so I don't know if the other stuff matters. My laptop came with 32 bit vista, if that matters. Sorry if this is a stupid question. Thanks.
    Last edited by Tux the penguin (2010-11-23 20:01:40)

    Thanks for the quick reply. Sorry. I should have been more clear. By everything else I meant for example:
    *-pci:1
    description: PCI bridge
    product: MCP79 PCI Express Bridge
    vendor: nVidia Corporation
    physical id: 10
    bus info: pci@0000:00:10.0
    version: b1
    width: 32 bits
    clock: 33MHz
    capabilities: pci pm msi normal_decode bus_master cap_list
    resources: ioport:d000(size=4096) memory:faf00000-fbffffff ioport:e0000000(size=402653184)
    -storage
    description: SATA controller
    product: MCP79 AHCI Controller
    vendor: nVidia Corporation
    physical id: b
    bus info: pci@0000:00:0b.0
    logical name: scsi0
    logical name: scsi1
    version: b1
    width: 32 bits
    clock: 66MHz
    capabilities: storage pm msi ahci_1.0 bus_master cap_list emulated
    configuration: driver=ahci latency=0 maxlatency=1 mingnt=3
    resources: irq:42 ioport:c000(size=8) ioport:bc00(size=4) ioport:b880(size=8) ioport:b800(size=4) ioport:b480(size=16) memory:fae72000-fae73fff
    *-multimedia
    description: Audio device
    product: MCP79 High Definition Audio
    vendor: nVidia Corporation
    physical id: 8
    bus info: pci@0000:00:08.0
    version: b1
    width: 32 bits
    clock: 66MHz
    capabilities: pm bus_master cap_list
    configuration: driver=HDA Intel latency=0 maxlatency=5 mingnt=2
    resources: irq:21 memory:fae78000-fae7bfff
    *-network
    description: Ethernet interface
    product: MCP79 Ethernet
    vendor: nVidia Corporation
    physical id: a
    bus info: pci@0000:00:0a.0
    logical name: eth0
    version: b1
    serial: 00:24:21:6d:a4:82
    capacity: 1Gbit/s
    width: 32 bits
    clock: 66MHz
    capabilities: pm bus_master cap_list ethernet physical mii 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
    configuration: autonegotiation=on broadcast=yes driver=forcedeth driverversion=0.64 latency=0 link=no maxlatency=20 mingnt=1 multicast=yes port=MII
    resources: irq:20 memory:fae7d000-fae7dfff ioport:c080(size=8) memory:fae7e800-fae7e8ff memory:fae7e400-fae7e40f
    description: Notebook
    product: CR600 (To Be Filled By O.E.M.)
    vendor: Micro-Star International
    version: Ver 1.000
    serial: System Serial Number
    width: 32 bits
    capabilities: smbios-2.6 dmi-2.6 smp-1.4 smp
    configuration: boot=normal chassis=notebook cpus=2 family=To Be Filled By O.E.M. sku=To Be Filled By O.E.M. uuid=00020003-0004-0005-0006-000700080009
    Processor details-
    *-cpu:0
    description: CPU
    product: Pentium(R) Dual-Core CPU T4200 @ 2.00GHz
    vendor: Intel Corp.
    physical id: 4
    bus info: cpu@0
    version: 6.7.10
    serial: 0001-067A-0000-0000-0000-0000
    slot: CPU 1
    size: 2GHz
    capacity: 2GHz
    width: 64 bits
    clock: 200MHz
    capabilities: x86-64 boot fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm xsave lahf_lm
    configuration: cores=2 enabledcores=2 id=1 threads=2
    So, I could still run a 64 bit OS, even though most of the hardware is 32 bit?
    Last edited by Tux the penguin (2010-11-23 02:57:18)

  • Loading Illustrator 8.0 in Windows 7 64 bit operating system.

    I just bought a new Dell Desktop that has Windows 7 64 bit operating system.
    My old version of Illustrator 8.0 at Set Up will not load ?
    Is there a work around for 64 bit ?
    [ private contact info removed]

    Larry
    Thank you…time to upgrade Illustrator.
    Rich

  • Getting Error for Install of Prerequisite Components in 64 bit operating system

    we have generated our .exe file by adding prerequisite  in setup project and prerequisite (sql server 2005 Express
    sp2 (x86)) works for windows xp. But we are facing an issue while we install prerequisite (sql server 2005 Express sp2 (x86))  not working in windows 7 64 bit and 32  bit operating system. We have added prerequisite (sql server 2005 Express sp2 (x86))
    using visual studio 2010.While we install prerequisite (sql server 2005 Express sp2 (x86)) in windows 7 we getting error like " Prerequisite check for system component SQL Server 2005 Express Edition SP2 (x86) failed with the following error message:
    "This version of SQL Server 2005 Express Edition (x86) is not supported for the current processor architecture."
    See the setup log file located at 'C:\Users\BS-90\AppData\Local\Temp\VSDCFFC.tmp\install.log' for more information.
      ". We need only sql server 2005 express edition to be installed but not sql server 2008 express edition to be
    placed as prerequisite for our application because our .mdf file supports sql server 2005 express edition only.

    Hello Zhang,
                        As per your reply here is my summary  fallows as:
                       Microsoft SQL Server 2005 9.00.3042.00 
                       ============================== 
                       OS Version      : Professional Service Pack 1 (Build 7601) 
                       Time            : Mon Nov 10 14:55:46 2014 
                       BS-90-PC : The feature(s) specified are not valid for this edition of SQL Server.
     SQL Server Setup failed. For more information, review the Setup log file in %ProgramFiles%\Microsoft SQL Server\90\Setup Bootstrap\LOG\Summary.txt. 
    Time            : Mon Nov 10 14:55:50 2014
    List of log files:
    C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG\Files\SQLSetup0002_BS-60-PC_Core(Local).log
    C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG\Files\SQLSetup0002_BS-60-PC_Datastore.xml
    C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG\Files\SQLSetup0002_BS-60-PC_.NET Framework 2.0.log
    C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG\Files\SQLSetup0002_BS-60-PC_Support.log
    C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG\Files\SQLSetup0002_BS-60-PC_Core.log
    C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG\Summary.txt
    C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG\Files\SQLSetup0002_BS-60-PC_SCC.log
    And Detail Logs fallows as:
    The following properties have been set:
    Property: [AdminUser] = true {boolean}
    Property: [InstallMode] = HomeSite {string}
    Property: [ProcessorArchitecture] = AMD64 {string}
    Property: [VersionNT] = 6.1.1 {version}
    Running checks for package 'Windows Installer 3.1', phase BuildList
    The following properties have been set for package 'Windows Installer 3.1':
    Running checks for command 'WindowsInstaller3_1\WindowsInstaller-KB893803-v2-x86.exe'
    Result of running operator 'VersionGreaterThanOrEqualTo' on property 'VersionMsi' and value '3.1': true
    Result of checks for command 'WindowsInstaller3_1\WindowsInstaller-KB893803-v2-x86.exe' is 'Bypass'
    'Windows Installer 3.1' RunCheck result: No Install Needed
    Running checks for package 'SQL Server 2005 Express Edition SP2 (x86)', phase BuildList
    Running external check with command 'C:\Users\BS-90\AppData\Local\Temp\VSDCFFC.tmp\SqlExpress\SqlExpressChk.exe' and parameters ''
    Process exited with code 1
    Setting value '1 {int}' for property 'SQLExpressInstalled'
    The following properties have been set for package 'SQL Server 2005 Express Edition SP2 (x86)':
    Property: [SQLExpressInstalled] = 1 {int}
    Running checks for command 'SqlExpress\sqlexpr32.exe'
    Result of running operator 'ValueEqualTo' on property 'SQLExpressInstalled' and value '0': false
    Result of running operator 'VersionGreaterThanOrEqualTo' on property 'VersionNT' and value '5.1': true
    Result of checks for command 'SqlExpress\sqlexpr32.exe' is 'Bypass'
    Running checks for command 'SqlExpress\sqlexpr32.exe'
    Result of running operator 'ValueEqualTo' on property 'SQLExpressInstalled' and value '0': false
    Result of running operator 'VersionLessThan' on property 'VersionNT' and value '5.1': false
    Result of running operator 'ValueEqualTo' on property 'AdminUser' and value 'false': false
    Result of running operator 'ValueExists' on property 'Version9x': false
    Result of running operator 'VersionLessThan' on property 'VersionNT' and value '5.1.2': false
    Result of running operator 'ValueNotEqualTo' on property 'ProcessorArchitecture' and value 'Intel': true
    Result of checks for command 'SqlExpress\sqlexpr32.exe' is 'Fail'
    'SQL Server 2005 Express Edition SP2 (x86)' RunCheck result: Fail
    A prerequisite failed for Package "SQL Server 2005 Express Edition SP2 (x86)"
    Package failed with message "This version of SQL Server 2005 Express Edition (x86) is not supported for the current processor architecture."

  • Whether postgresql-8.2-506.jdbc4 works in a 64 bit operating system?

    Whether **postgresql-8.2-506.jdbc4** works in a 64 bit operating system?
    Especially I would like to know whether it works in windows server 2008 64 bit operating system.

    masijade. wrote:
    :sigh:
    IOW, Go to a PostGreSQL site and ask there!
    The Driver is produced by them, they should know. I don't believe it would be a problem, but all you can do is try it.Agreed.
    The postgresql JDBC driver is a type 4 driver and therefor a pure Java implementation without JNI dependencies. That should work without problems on a 64 bit system.

  • Bit Operations

    I'm attempting to do some bit operations on a decimal value that I need to output as binary to my instrument. Using universal libraries Digital out vi, I can send an integer value out as a binary number. Is it possible to perform bit operations on a decimal value using the formula node and logical operators? I need to make the LSB, the MSB. For example, a decimal value of 128 in binary is 10000000. I would need to output this as 00000001. I was trying to use a formula node like this: y = (x && 1) ? 128:0 ..... y = (x && 128) ? 1:0 for all the eight bit values. Then I would add all the values up and send that to DOUT. So in my example beginning with a decimal value of 128 and sending it to eight formula nodes I would like to get false values unti
    l y = (x && 128) ? 1:0. Then the compound addition would yield one and this value would be sent out to my instrument as binary 00000001. Unfortunately, I get true values out of all my formula nodes. How can I accomplish the bit operations I need to perform on a decimal value and then send it as an integer value to DOUT? The example is simplified, the actual decimal values are large. Any help would be greatly appreciated.

    I don't know about the formula node but you could just use a few labview functions. Change it into an array of bits using number to boolean array and boolean to (0,1). Use reverse array and then change it back to a number using 'not equal to zero?' and boolean array to number. Not sure if that is better or simpler than using a formula node but it is another option.

  • INdesign and 64 Bit Operating Systems

    Been having problems with my INdesign, and the tech people on the support line said it is because I have Vista 64 bit operating system. This sounds very strange to me, as INdesign is the industry standard, and 64 bit operating systems are the norm. Does any one else have experience trying to run INdesign on a 64 bit system?

    Bob's right; I'd suggest ignoring the 64-bit issue and just getting familiar with coming to the forums for assistance. I've worked phone tech-support jobs before; phone support reps are judged by how fast they can get you off the phone, and if you start the call with "Hey, I'm running ID on a 64-bit system" then they can get you off the phone immediately, so you just gave their call-time metrics an easy statistical boost.
    1) So, yeah, the baseline grid will cause stuff to snap to it if you have that setting turned on in the "Grids & Guides" section of the View menu.
    2) "Manual overrides" means that you can format text manually by clicking on the Font menu, and that will cause your formatting to diverge from what is defined in the style. Take a look at the style name; does it have a little plus next to it? That means that the text you've selected diverges from the style. Clear the overrides to return the text to the settings in the paragraph style. You can do this with an alt-click on the style name, or by clicking on the options pulldown in the Paragraph Styles panel and choosing "Clear Overrides." I do it so often that I have a keyboard shortcut set up to do it (in Edit -> Keyboard Shortcuts).

Maybe you are looking for

  • How do i sign into my apple ID from the Apple homepage?

    I need to sign into my apple account and try and backup my broken Iphone 5 before i go and hand it in to Best Buy . I have a passcode on my phone and my screen is broken, so i cant get into to it. The man at Best Buy said to try and back my phone up

  • ITunes:  How can multiple accounts on one iMac share a single iTunes library?

    I have a single iMac with multiple user accounts.  How can I share a single itunes music library with all users? Thanks for your input!!

  • Display of Report Totals of different groups

    Hi I have a requirement in XML Publisher where in I need to display the Total of all the sub totals of the 3 groups which i am currently working on. I am able to display the sub group totals . Example A B 100 200 -----------Group 1 C D 30 50 --------

  • Click the lock to make changes

    I have a clean install of Mountain Lion OS X on a Mid 2010 Macbook Pro.  I'm running into a problem when I go to click on the lock in any System Preferences window.  I go to click on the lock and nothing happens.  It does a short stutter, but then I

  • 13" Haswell MacBook Pro with Retina Display overheats and speakers fail.

         I have the new 13" Haswell MacBook Pro with Retina Display. Have had it for a week and a half now and ever since I got it the speakers have failed completely many times. They start to crackle then stop completely. The speakers just don't respond