本文整理汇总了Java中com.keepassdroid.stream.LEDataOutputStream类的典型用法代码示例。如果您正苦于以下问题:Java LEDataOutputStream类的具体用法?Java LEDataOutputStream怎么用?Java LEDataOutputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LEDataOutputStream类属于com.keepassdroid.stream包,在下文中一共展示了LEDataOutputStream类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeCString
import com.keepassdroid.stream.LEDataOutputStream; //导入依赖的package包/类
public static int writeCString(String str, OutputStream os) throws IOException {
if ( str == null ) {
// Write out a null character
os.write(LEDataOutputStream.writeIntBuf(1));
os.write(0x00);
return 0;
}
if ( REPLACE ) {
str = str.replace(SEP, CRLF);
}
byte[] initial = str.getBytes("UTF-8");
int length = initial.length+1;
os.write(LEDataOutputStream.writeIntBuf(length));
os.write(initial);
os.write(0x00);
return length;
}
示例2: writeByteArray
import com.keepassdroid.stream.LEDataOutputStream; //导入依赖的package包/类
private int writeByteArray(byte[] data) throws IOException {
int dataLen;
if ( data != null ) {
dataLen = data.length;
} else {
dataLen = 0;
}
mOS.write(BINARY_DATA_FIELD_TYPE);
mOS.write(LEDataOutputStream.writeIntBuf(dataLen));
if ( data != null ) {
mOS.write(data);
}
return dataLen;
}
示例3: makePad
import com.keepassdroid.stream.LEDataOutputStream; //导入依赖的package包/类
/**
* KeePass's custom pad style.
*
* @param data buffer to pad.
* @return addtional bytes to append to data[] to make
* a properly padded array.
*/
public static byte[] makePad( byte[] data ) {
//custom pad method
// append 0x80 plus zeros to a multiple of 4 bytes
int thisblk = 32 - data.length % 32; // bytes needed to finish blk
int nextblk = 0; // 32 if we need another block
// need 9 bytes; add new block if no room
if( thisblk < 9 ) {
nextblk = 32;
}
// all bytes are zeroed for free
byte[] pad = new byte[ thisblk + nextblk ];
pad[0] = (byte)0x80;
// write length*8 to end of final block
int ix = thisblk + nextblk - 8;
LEDataOutputStream.writeInt( data.length>>29, pad, ix );
bsw32( pad, ix );
ix += 4;
LEDataOutputStream.writeInt( data.length<<3, pad, ix );
bsw32( pad, ix );
return pad;
}
示例4: UUIDtoBytes
import com.keepassdroid.stream.LEDataOutputStream; //导入依赖的package包/类
public static byte[] UUIDtoBytes(UUID uuid) {
byte[] buf = new byte[16];
LEDataOutputStream.writeLong(uuid.getMostSignificantBits(), buf, 0);
LEDataOutputStream.writeLong(uuid.getLeastSignificantBits(), buf, 8);
return buf;
}
示例5: output
import com.keepassdroid.stream.LEDataOutputStream; //导入依赖的package包/类
public void output() throws IOException {
mOS.write(LEDataOutputStream.writeIntBuf(mHeader.signature1));
mOS.write(LEDataOutputStream.writeIntBuf(mHeader.signature2));
mOS.write(LEDataOutputStream.writeIntBuf(mHeader.flags));
mOS.write(LEDataOutputStream.writeIntBuf(mHeader.version));
mOS.write(mHeader.masterSeed);
mOS.write(mHeader.encryptionIV);
mOS.write(LEDataOutputStream.writeIntBuf(mHeader.numGroups));
mOS.write(LEDataOutputStream.writeIntBuf(mHeader.numEntries));
mOS.write(mHeader.contentsHash);
mOS.write(mHeader.transformSeed);
mOS.write(LEDataOutputStream.writeIntBuf(mHeader.numKeyEncRounds));
}
示例6: output
import com.keepassdroid.stream.LEDataOutputStream; //导入依赖的package包/类
public void output() throws IOException {
//NOTE: Need be to careful about using ints. The actual type written to file is a unsigned int, but most values can't be greater than 2^31, so it probably doesn't matter.
// Group ID
mOS.write(GROUPID_FIELD_TYPE);
mOS.write(GROUPID_FIELD_SIZE);
mOS.write(LEDataOutputStream.writeIntBuf(mPG.groupId));
// Name
mOS.write(NAME_FIELD_TYPE);
Types.writeCString(mPG.name, mOS);
// Create date
mOS.write(CREATE_FIELD_TYPE);
mOS.write(DATE_FIELD_SIZE);
mOS.write(mPG.tCreation.getCDate());
// Modification date
mOS.write(MOD_FIELD_TYPE);
mOS.write(DATE_FIELD_SIZE);
mOS.write(mPG.tLastMod.getCDate());
// Access date
mOS.write(ACCESS_FIELD_TYPE);
mOS.write(DATE_FIELD_SIZE);
mOS.write(mPG.tLastAccess.getCDate());
// Expiration date
mOS.write(EXPIRE_FIELD_TYPE);
mOS.write(DATE_FIELD_SIZE);
mOS.write(mPG.tExpire.getCDate());
// Image ID
mOS.write(IMAGEID_FIELD_TYPE);
mOS.write(IMAGEID_FIELD_SIZE);
mOS.write(LEDataOutputStream.writeIntBuf(mPG.icon.iconId));
// Level
mOS.write(LEVEL_FIELD_TYPE);
mOS.write(LEVEL_FIELD_SIZE);
mOS.write(LEDataOutputStream.writeUShortBuf(mPG.level));
// Flags
mOS.write(FLAGS_FIELD_TYPE);
mOS.write(FLAGS_FIELD_SIZE);
mOS.write(LEDataOutputStream.writeIntBuf(mPG.flags));
// End
mOS.write(END_FIELD_TYPE);
mOS.write(ZERO_FIELD_SIZE);
}
示例7: output
import com.keepassdroid.stream.LEDataOutputStream; //导入依赖的package包/类
public void output() throws IOException {
outputBytes += 134; // Length of fixed size fields
// UUID
mOS.write(UUID_FIELD_TYPE);
mOS.write(UUID_FIELD_SIZE);
mOS.write(Types.UUIDtoBytes(mPE.getUUID()));
// Group ID
mOS.write(GROUPID_FIELD_TYPE);
mOS.write(LONG_FOUR);
mOS.write(LEDataOutputStream.writeIntBuf(mPE.groupId));
// Image ID
mOS.write(IMAGEID_FIELD_TYPE);
mOS.write(LONG_FOUR);
mOS.write(LEDataOutputStream.writeIntBuf(mPE.icon.iconId));
// Title
//byte[] title = mPE.title.getBytes("UTF-8");
mOS.write(TITLE_FIELD_TYPE);
int titleLen = Types.writeCString(mPE.title, mOS);
outputBytes += titleLen;
// URL
mOS.write(URL_FIELD_TYPE);
int urlLen = Types.writeCString(mPE.url, mOS);
outputBytes += urlLen;
// Username
mOS.write(USERNAME_FIELD_TYPE);
int userLen = Types.writeCString(mPE.username, mOS);
outputBytes += userLen;
// Password
byte[] password = mPE.getPasswordBytes();
mOS.write(PASSWORD_FIELD_TYPE);
mOS.write(LEDataOutputStream.writeIntBuf(password.length+1));
mOS.write(password);
mOS.write(0);
outputBytes += password.length + 1;
// Additional
mOS.write(ADDITIONAL_FIELD_TYPE);
int addlLen = Types.writeCString(mPE.additional, mOS);
outputBytes += addlLen;
// Create date
writeDate(CREATE_FIELD_TYPE, mPE.tCreation.getCDate());
// Modification date
writeDate(MOD_FIELD_TYPE, mPE.tLastMod.getCDate());
// Access date
writeDate(ACCESS_FIELD_TYPE, mPE.tLastAccess.getCDate());
// Expiration date
writeDate(EXPIRE_FIELD_TYPE, mPE.tExpire.getCDate());
// Binary desc
mOS.write(BINARY_DESC_FIELD_TYPE);
int descLen = Types.writeCString(mPE.binaryDesc, mOS);
outputBytes += descLen;
// Binary data
int dataLen = writeByteArray(mPE.getBinaryData());
outputBytes += dataLen;
// End
mOS.write(END_FIELD_TYPE);
mOS.write(ZERO_FIELD_SIZE);
}