encryption - C# Have user input string to a key DES -
in c# programme encrypting/decrypting files. copied code microsoft website toy , dissect it. i'm asking if of know how have pre-determined string deed key encryption/decryption.
in main method:
string ssecretkey; ssecretkey = generatekey();
generatekey:
static string generatekey() { descryptoserviceprovider descrypto = (descryptoserviceprovider) descryptoserviceprovider.create(); homecoming asciiencoding.ascii.getstring(descrypto.key); }
this in encrypt , decrypt function: have no thought do
des.key = asciiencoding.ascii.getbytes(skey); des.iv = asciiencoding.ascii.getbytes(skey);
this sort of depends on want do. in next line...
asciiencoding.ascii.getstring(descrypto.key);
you fetching ascii representation of automatically generated key encryption object. property des.key
though, has both public set
, public get
, can do:
// set key pre-determined set of bytes (of length 8): descrypto.key = new byte[] {0x4b, 0x4a, 0x41, 0x52, 0x54, 0x41, 0x4e, 0x21};
ofcourse value of this, when next line decodes descrypto.key
string, bytes "decoded" hex more readable ascii characters (assuming you've provided meaningful hex values begin with, ofcourse).
c# encryption key des
No comments:
Post a Comment