`
jacky-zhang
  • 浏览: 315661 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Encrypting an Object with DES

 
阅读更多
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";
}
分享到:
评论

相关推荐

    DES资料详细介绍

    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 ...

    MAC3DES加密组件

    NSLog(@"Error encrypting data: %d", status); } return encryptedData; } ``` 这个函数接受明文数据和密钥,返回加密后的数据。`kCCEncrypt`表示加密操作,`kCCAlgorithm3DES`指定了3DES算法,`...

    AES.rar_AES_AES 加密_AES文件加密_encrypting with java

    AES由美国国家标准与技术研究所(NIST)于2001年正式采纳,取代了之前的DES(数据加密标准)成为新的政府标准。AES在信息安全领域扮演着至关重要的角色,被广泛应用于数据存储、网络通信以及软件保护等方面。 **AES...

    Encrypting_File_System概述

    ### Encrypting File System (EFS) 概述:深度解析微软Windows软件加密系统 #### 一、何谓EFS? EFS(Encrypting File System),即加密文件系统,是由微软自Windows 2000系列以来引入的一个核心安全功能,旨在为...

    Lab 1_encrypting_

    对称加密,如DES(数据加密标准)和AES(高级加密标准),使用同一密钥进行加密和解密。由于效率高,它适用于大量数据的加密。然而,密钥的管理和分发成为主要挑战,因为如果密钥丢失或被盗,数据安全就会受到威胁。...

    Encrypting and decrypting sensitive data using CryptoAPI. (6

    标题中的“Encrypting and decrypting sensitive data using CryptoAPI”指的是使用Windows操作系统提供的CryptoAPI来对敏感数据进行加密和解密的技术。CryptoAPI是微软提供的一组接口,它允许程序员实现安全的加密...

    Hacking.Secret.Ciphers.with.Python.B00WOY87ZU

    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 ...

    Remote Desktop Connection Manager v2.83

    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...

    Encrypting Safe-开源

    《Encrypting Safe:开源的秘密守护者》 在数字化时代,数据安全成为了我们关注的重要话题,尤其是在个人隐私和敏感信息的保护上。 Encrypting Safe 是一个专为此设计的开源Java桌面应用,它以其强大的加密功能,为...

    aaes.zip_Adopted

    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.

    LockBox2.5

    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 ...

    The Craft of System Security

    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 ...

    ExeScript.Editor.v2.6.1.0.incl.serial-iOTA

    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. ...

    The Busy Coder's Guide to Android Development 8.10

    • 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 ...

    能编译的ECC源码

    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...

    MuPDF是一个PDF格式分析器,用来阅读PDF文件,并创建Fitz trees。

    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 ...

    DCPcrypt(v3b3 UNICODE修正)+2个Demo

    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.

    DNA_meself.rar_DNA 加密_DNA加密_DNA图像加密_image encrypting_图像 加密

    利用DNA加密,将图像加密,啊啊啊啊啊啊啊啊啊啊

Global site tag (gtag.js) - Google Analytics