Decode PEM (c#) -
I have picked some old code with which I need to work and I have the following functions in C
< Pre> int pem64_decode_bytes (const char * intext, int nchars, unsigned char * outbit) {unsigned char * outbcopy = outbytes; Whereas (nchars> = 4) {char c1 = intext [0], c2 = intext [1], c3 = intext [2], c4 = intext [3]; Int b1 = pem64_dict_offset (c1), b2 = pem64_dict_offset (c2), b3 = pem64_dict_offset (c3), b4 = pem64_dict_offset (c4); If ((b1 == -1) || (b2 == -1) || (b3 == -1) || (b4 == -1)) outbound return - outcopy; * (Outbite ++) = (B1 Lieutenic; > 4); If (C3! = Filarisms) * (Outbite ++) = ((B2 and 0x F) & lt; <4) | (B3> 2); If (C4! = Filarar) * (Outbite ++) = ((B3 and 0x3) It should decode a pack of data encoded. Does anyone know that this is a standard task? I need to convert it to C #, I'm not a C codeer, does anyone know of a sample that does this?
Edit
=======
Public Static List & lt; Byte & gt; Pem64_decode_bytes (string intake, int number overbits) {var rated data = new list & lt; Byte & gt; (); While (numberofbits> = 4) {char c1 = InText [0]; Four C2 = Intact [1]; Four c3 = intake [2]; Four c4 = intake [3]; Int b1 = pem64_dict_offset (c1); Int b2 = pem64_dict_offset (c2); Int b3 = pem64_dict_offset (c3); Int b4 = pem64_dict_offset (c4); If (B1 == -1 || B2 == -1 || B3 == -1 || B4 == -1) Return (RatedData); } (Outbited) ++. Deaf = B1 < & Lt; 2 | B2 & gt; & Gt; 4; If (C3! = FILLERCHAR) {(outbytes) ++ Defe = (B2 and 0xf) & lt; & Lt; 4 | B3 & gt; & Gt; 2; } If (c4! = Filariness) {(outbites) ++. Defe = (B3 and 0x3) & lt; & Lt; 6 | B4; } Numberofbyte - = 4; } Return retention; }
Do you also have a source for pem64_dict_offset? I do not recognize it as a standard function, though it looks like base 64 decoding.
If so, then it may not be very difficult to change C #.
* (Outbite ++) thing which is probably terrible for non-C programmer, is just adding a byte to the block of bytes.
The AC # will be analogous:
list & lt; Byte & gt; Outbits = new list & lieutenant; Byte & gt; () Outbite. Add (new byte)
'Outbound outbait-outback' will be 'Return Outback'. Instead of expecting the caller to assign it to you, it will be more common (however, in C # to return to the list.
Comments
Post a Comment