protected static SecretKey generateSecretKey(String password, EncryptionVerifier ver) { if (password.length() > 255) { password = password.substring(0, 255); } HashAlgorithm hashAlgo = ver.getHashAlgorithm(); MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo); hashAlg.update(ver.getSalt()); byte hash[] = hashAlg.digest(StringUtil.getToUnicodeLE(password)); return new SecretKeySpec(hash, ver.getCipherAlgorithm().jceId); }
protected static SecretKey generateSecretKey(String password, EncryptionVerifier ver) { if (password.length() > 255) { password = password.substring(0, 255); } HashAlgorithm hashAlgo = ver.getHashAlgorithm(); MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo); byte hash[] = hashAlg.digest(StringUtil.getToUnicodeLE(password)); byte salt[] = ver.getSalt(); hashAlg.reset(); for (int i = 0; i < 16; i++) { hashAlg.update(hash, 0, 5); hashAlg.update(salt); } hash = new byte[5]; System.arraycopy(hashAlg.digest(), 0, hash, 0, 5); return new SecretKeySpec(hash, ver.getCipherAlgorithm().jceId); }
public void setFileName(String data){ // TODO: add trailing \u0000? byte bytes[] = StringUtil.getToUnicodeLE(data); EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.BLIP__BLIPFILENAME, true, bytes); setPropertyValue(prop); }
byte[] hash = hashAlg.digest(StringUtil.getToUnicodeLE(password)); byte[] iterator = new byte[LittleEndianConsts.INT_SIZE];
public static void writeUnicodeLPP4(LittleEndianOutput os, String string) { byte buf[] = StringUtil.getToUnicodeLE(string); os.writeInt(buf.length); os.write(buf); if (buf.length%4==2) { os.writeShort(0); } }
LittleEndian.putUInt(buf, 0, sde.reserved2); bos.write(buf, 0, 4); byte nameBytes[] = StringUtil.getToUnicodeLE(sde.streamName); bos.write(nameBytes, 0, nameBytes.length); LittleEndian.putShort(buf, 0, (short)0); // null-termination
/** * serializes the header */ @Override public void write(LittleEndianByteArrayOutputStream bos) { int startIdx = bos.getWriteIndex(); LittleEndianOutput sizeOutput = bos.createDelayedOutput(LittleEndianConsts.INT_SIZE); bos.writeInt(getFlags()); bos.writeInt(0); // size extra bos.writeInt(getCipherAlgorithm().ecmaId); bos.writeInt(getHashAlgorithm().ecmaId); bos.writeInt(getKeySize()); bos.writeInt(getCipherProvider().ecmaId); bos.writeInt(0); // reserved1 bos.writeInt(0); // reserved2 String cspName = getCspName(); if (cspName == null) { cspName = getCipherProvider().cipherProviderName; } bos.write(StringUtil.getToUnicodeLE(cspName)); bos.writeShort(0); int headerSize = bos.getWriteIndex()-startIdx-LittleEndianConsts.INT_SIZE; sizeOutput.writeInt(headerSize); }
public SinglentonTextPiece( StringBuilder buffer ) { super( 0, buffer.length(), StringUtil.getToUnicodeLE(buffer.toString()), new PieceDescriptor( new byte[8], 0 ) ); }
/** * Set the name of the font. * The length of this string must not exceed 32 characters * including the null terminator. * Will be converted to null-terminated if not already * @param name of the font */ public void setFontName(String name) { // Ensure it's not now too long int nameLen = name.length() + (name.endsWith("\u0000") ? 0 : 1); if (nameLen > 32) { throw new HSLFException("The length of the font name, including null termination, must not exceed 32 characters"); } // Everything's happy, so save the name byte[] bytes = StringUtil.getToUnicodeLE(name); System.arraycopy(bytes, 0, _recdata, 0, bytes.length); // null the remaining bytes Arrays.fill(_recdata, 64-bytes.length, 64, (byte)0); }
private void storeString() { if (getType() == Types.ASCII_STRING) { rawValue = value.getBytes(Charset.forName(encoding7Bit)); } else if (getType() == Types.UNICODE_STRING) { rawValue = StringUtil.getToUnicodeLE(value); } else { throw new IllegalArgumentException("Invalid type " + getType() + " for String Chunk"); } }
protected static SecretKey generateSecretKey(String password, EncryptionVerifier ver) { if (password.length() > 255) { password = password.substring(0, 255); } HashAlgorithm hashAlgo = ver.getHashAlgorithm(); MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo); hashAlg.update(ver.getSalt()); byte hash[] = hashAlg.digest(StringUtil.getToUnicodeLE(password)); return new SecretKeySpec(hash, ver.getCipherAlgorithm().jceId); }
public void setFileName(String data){ // TODO: add trailing \u0000? byte bytes[] = StringUtil.getToUnicodeLE(data); EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.BLIP__BLIPFILENAME, true, bytes); setPropertyValue(prop); }
protected static SecretKey generateSecretKey(String password, EncryptionVerifier ver) { if (password.length() > 255) { password = password.substring(0, 255); } HashAlgorithm hashAlgo = ver.getHashAlgorithm(); MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo); byte hash[] = hashAlg.digest(StringUtil.getToUnicodeLE(password)); byte salt[] = ver.getSalt(); hashAlg.reset(); for (int i = 0; i < 16; i++) { hashAlg.update(hash, 0, 5); hashAlg.update(salt); } hash = new byte[5]; System.arraycopy(hashAlg.digest(), 0, hash, 0, 5); return new SecretKeySpec(hash, ver.getCipherAlgorithm().jceId); }
byte[] hash = hashAlg.digest(StringUtil.getToUnicodeLE(password)); byte[] iterator = new byte[LittleEndianConsts.INT_SIZE];
/** * Name of this picture. * * @param name of this picture */ public void setPictureName(String name){ AbstractEscherOptRecord opt = getEscherOptRecord(); byte[] data = StringUtil.getToUnicodeLE(name + '\u0000'); EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.BLIP__BLIPFILENAME, false, data); opt.addEscherProperty(prop); }
public static void writeUnicodeLPP4(LittleEndianOutput os, String string) { byte buf[] = StringUtil.getToUnicodeLE(string); os.writeInt(buf.length); os.write(buf); if (buf.length%4==2) { os.writeShort(0); } }
@Override protected void afterInsert(HSLFSheet sheet){ ExControl ctrl = getExControl(); if (ctrl == null) { throw new NullPointerException("ExControl is not defined"); } ctrl.getExControlAtom().setSlideId(sheet._getSheetNumber()); String name = ctrl.getProgId() + "-" + getControlIndex() + '\u0000'; byte[] data = StringUtil.getToUnicodeLE(name); EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.GROUPSHAPE__SHAPENAME, false, data); AbstractEscherOptRecord opt = getEscherOptRecord(); opt.addEscherProperty(prop); } }
LittleEndian.putUInt(buf, 0, sde.reserved2); bos.write(buf, 0, 4); byte nameBytes[] = StringUtil.getToUnicodeLE(sde.streamName); bos.write(nameBytes, 0, nameBytes.length); LittleEndian.putShort(buf, 0, (short)0); // null-termination
/** * serializes the header */ @Override public void write(LittleEndianByteArrayOutputStream bos) { int startIdx = bos.getWriteIndex(); LittleEndianOutput sizeOutput = bos.createDelayedOutput(LittleEndianConsts.INT_SIZE); bos.writeInt(getFlags()); bos.writeInt(0); // size extra bos.writeInt(getCipherAlgorithm().ecmaId); bos.writeInt(getHashAlgorithm().ecmaId); bos.writeInt(getKeySize()); bos.writeInt(getCipherProvider().ecmaId); bos.writeInt(0); // reserved1 bos.writeInt(0); // reserved2 String cspName = getCspName(); if (cspName == null) { cspName = getCipherProvider().cipherProviderName; } bos.write(StringUtil.getToUnicodeLE(cspName)); bos.writeShort(0); int headerSize = bos.getWriteIndex()-startIdx-LittleEndianConsts.INT_SIZE; sizeOutput.writeInt(headerSize); }