1 package org.bouncycastle.crypto; 2 3 /** 4 * Standard char[] to byte[] converters for password based derivation algorithms. 5 */ 6 public enum PasswordConverter 7 implements CharToByteConverter 8 { 9 /** 10 * Do a straight char[] to 8 bit conversion. 11 */ 12 ASCII 13 { getType()14 public String getType() 15 { 16 return "ASCII"; 17 } 18 convert(char[] password)19 public byte[] convert(char[] password) 20 { 21 return PBEParametersGenerator.PKCS5PasswordToBytes(password); 22 } 23 }, 24 /** 25 * Do a char[] conversion by producing UTF-8 data. 26 */ 27 UTF8 28 { getType()29 public String getType() 30 { 31 return "UTF8"; 32 } 33 convert(char[] password)34 public byte[] convert(char[] password) 35 { 36 return PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(password); 37 } 38 }, 39 /** 40 * Do char[] to BMP conversion (i.e. 2 bytes per character). 41 */ 42 PKCS12 43 { getType()44 public String getType() 45 { 46 return "PKCS12"; 47 } 48 convert(char[] password)49 public byte[] convert(char[] password) 50 { 51 return PBEParametersGenerator.PKCS12PasswordToBytes(password); 52 } 53 }; 54 } 55