Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

13
LINES

< > BotCompany Repo | #1005123 // crypto_makeAESKey

JavaX fragment (include)

import javax.crypto.*;

static SecretKey crypto_makeAESKey(S password, byte[] salt) ctex {
  SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
    
  // only with unlimited strength:
  //KeySpec spec = new PBEKeySpec(password, salt, 65536, 256);
  
  // Let's try this:
  KeySpec spec = new PBEKeySpec(toCharArray(password), salt, 65536, 128);
  
  ret new SecretKeySpec(factory.generateSecret(spec).getEncoded(), "AES");
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005123
Snippet name: crypto_makeAESKey
Eternal ID of this version: #1005123/1
Text MD5: c20692728a1e65ea116a49ea290b0db5
Author: stefan
Category: javax / cryptography
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-10-16 21:18:00
Source code size: 464 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 405 / 415
Referenced in: [show references]