try {
// Generate a temporary key. In practice, you would save this key.
// See also Encrypting with DES Using a Pass Phrase.
SecretKey key = KeyGenerator.getInstance("DES").generateKey();
// Prepare the encrypter
Cipher ecipher = Cipher.getInstance("DES");
ecipher.init(Cipher.ENCRYPT_MODE, key);
// Seal (encrypt) the object
SealedObject so = new SealedObject(new MySecretClass(), ecipher);
// Get the algorithm used to seal the object
String algoName = so.getAlgorithm(); // DES
// Prepare the decrypter
Cipher dcipher = Cipher.getInstance("DES");
dcipher.init(Cipher.DECRYPT_MODE, key);
// Unseal (decrypt) the class
MySecretClass o = (MySecretClass)so.getObject(dcipher);
} catch (java.io.IOException e) {
} catch (ClassNotFoundException e) {
} catch (javax.crypto.IllegalBlockSizeException e) {
} catch (javax.crypto.BadPaddingException e) {
} catch (javax.crypto.NoSuchPaddingException e) {
} catch (java.security.NoSuchAlgorithmException e) {
} catch (java.security.InvalidKeyException e) {
}
public class MySecretClass implements java.io.Serializable {
String s = "the secret";
}
分享到:
相关推荐
If all keys are the same it is equivalent to encrypting once with just one key. If the first and last key are the same, the key length is 112 bits. If all 3 keys are the same, this is effectively the ...
AES加密程序,对一个文件或文档进行加密
介绍微软windows软件加密系统EFS。
chastotniy analiz
Chapter 8 - Encrypting with the Transposition Cipher Chapter 9 - Decrypting with the Transposition Cipher Chapter 10 - Programming a Program to Test Our Program Chapter 11 - Encrypting and Decrypting ...
Encrypting and decrypting sensitive data using CryptoAPI. (6KB)
This article presents an overview of AES and explains the algorithms it uses. Included is a complete C# implementation and examples of encrypting .NET data. After reading this article you will be ...
Passwords are stored securely by encrypting with either CryptProtectData using the (locally) logged on user's authority or an X509 certificate. User with OS versions prior to Win7/Vista will need to...
AES is based on the Rijndael cipher developed by two Belgian ... The algorithm described by AES is a symmetric-key algorithm, meaning the same key is used for both encrypting and decrypting the data.
The only way to do both is to have an Ansi and a Wide function for encrypting or decrypting strings. And that is what I've done. For example LockBox 2.07 has only one function BFEncryptStringEx. For ...
2.7 Object reuse with local variables 37 2.8 The Orange Book's path through the functionality/assurance space 41 4.1 Basic computer architecture 62 4.2 The memory management unit 65 4.3 Address ...
无水印,有目录,数字版,英文原版。 Ansible Playbook Essentials: Design automation blueprints using Ansible... Encrypting Data with Vault Managing Environments Orchestrating Infrastructure with Ansible
Supporting Batch, VBScript, WSF, WSH, HTA, JScript, Object Rexx, PerlScript, Python, and PowerShell scripting languages, Exe Script Editor makes it easy and comfortable to write and debug scripts. ...
• Adds a new chapter on working with the Android keystore, particularly for encrypting data with keys backed by device authentication, including through ngerprints • Migrates some more material out ...
Elliptic Curve Cryptography is an exciting and promising method of encrypting data which achieves the same, or better, strength with far smaller key lengths than traditional encryption methods such as...
A build with full CJK support (including an Asian font) is approximately five megabytes. MuPDF has support for all non-interactive PDF 1.7 features, and the toolkit provides a simple API for ...
Read the business pages or computer press and ...* The security of an organization's data and communications is critical to its survival * Brings Clarity to topics that are notoriously difficult to grasp
Bug in RC4 implementation: Ray Marron has reported a bug in the RC4 implementation in DCPcrypt that means that when encrypting data sets over 8192 bytes in size the results will non-standard.
Title: Learning iOS Security Author: Allister Banks, Charles S.... Encrypting Devices Chapter 4. Organizational Controls Chapter 5. Mobile Device Management Chapter 6. Debugging and Conclusion
利用DNA加密,将图像加密,啊啊啊啊啊啊啊啊啊啊