H
Hiline1961
Guest
Hello, I have some Java code that I'm trying to write in c#.
Here is the Java snippet:
byte[] keyBytes = key.getBytes();
SecretKey originalKey = new SecretKeySpec(keyBytes, 0, keyBytes.length, "AES");
JWEHeader header = new JWEHeader(JWEAlgorithm.A256GCMKW, EncryptionMethod.A256GCM);
Payload payload = new Payload(plainText);
JWEObject jweObject = new JWEObject(header, payload);
try {
jweObject.encrypt(new AESEncrypter(originalKey));
} catch (JOSEException e) {
return plainText;
}
String jweString = jweObject.serialize();
Here is what I have so far:
System.Text.UTF8Encoding utf8 = new UTF8Encoding();
AesManaged tdes = new AesManaged();
tdes.Key = utf8.GetBytes(key);
tdes.Mode = CipherMode.ECB;
tdes.Padding = PaddingMode.PKCS7;
I'd appreciate any assistance.
Thank you!
Continue reading...
Here is the Java snippet:
byte[] keyBytes = key.getBytes();
SecretKey originalKey = new SecretKeySpec(keyBytes, 0, keyBytes.length, "AES");
JWEHeader header = new JWEHeader(JWEAlgorithm.A256GCMKW, EncryptionMethod.A256GCM);
Payload payload = new Payload(plainText);
JWEObject jweObject = new JWEObject(header, payload);
try {
jweObject.encrypt(new AESEncrypter(originalKey));
} catch (JOSEException e) {
return plainText;
}
String jweString = jweObject.serialize();
Here is what I have so far:
System.Text.UTF8Encoding utf8 = new UTF8Encoding();
AesManaged tdes = new AesManaged();
tdes.Key = utf8.GetBytes(key);
tdes.Mode = CipherMode.ECB;
tdes.Padding = PaddingMode.PKCS7;
I'd appreciate any assistance.
Thank you!
Continue reading...