本文整理汇总了TypeScript中jcrypt类的典型用法代码示例。如果您正苦于以下问题:TypeScript jcrypt类的具体用法?TypeScript jcrypt怎么用?TypeScript jcrypt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了jcrypt类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: makeEntry
function makeEntry(entry: Entry): void {
jcrypt(keyFile, null, ['--decrypt'], true)
.then((data: string): string => {
const list = JSON.parse(data);
const item = list[entry.key] = {};
// TODO: Iterator.
for (let n in entry) {
if (entry.hasOwnProperty(n) && n !== 'key') {
item[n] = entry[n];
}
}
return jcrypt.stream(JSON.stringify(list, null, 4), keyFile, {
gpg: util.getGPGArgs(),
file: {
flags: 'w',
defaultEncoding: 'utf8',
fd: null,
mode: 0o0600
}
}, true);
})
.then((): void => logSuccess('Entry created successfully'))
.catch(logError);
}
开发者ID:btoll,项目名称:stymie-ts,代码行数:26,代码来源:generateEntry.ts
示例2: jcrypt
util.fileExists(path).then(() =>
jcrypt(path, null, ['--decrypt'])
.then((): void =>
openEditor(path, () =>
// Re-encrypt once done.
jcrypt(path, null, util.getGPGArgs())
.then(() => logInfo('Re-encrypting and closing the file'))
.catch(logError)
)
)
.catch(logError)
开发者ID:btoll,项目名称:stymie-ts,代码行数:11,代码来源:file.ts
示例3: getCredentials
function getCredentials(key: string): void {
jcrypt(keyFile, null, ['--decrypt'], true)
.then((data: string): void => {
const list = JSON.parse(data);
if (list[key]) {
logInfo('Key already exists');
} else {
inquirer.prompt([{
type: 'input',
name: 'url',
message: 'Enter url:',
validate: util.noBlanks
}, {
type: 'input',
name: 'username',
message: 'Enter username:',
validate: util.noBlanks
}, {
type: 'list',
name: 'generatePassword',
message: 'Generate diceware password?',
default: false,
choices: [
{name: 'Yes', value: true},
{name: 'No', value: false}
]
}, {
type: 'password',
name: 'password',
message: 'Enter password:',
validate: util.noBlanks,
when: answers => !answers.generatePassword
}], (answers: Answer) =>
makePassphrase({
key: key,
url: answers.url,
username: answers.username,
password: answers.password
})
);
}
})
.catch(logError);
}
开发者ID:btoll,项目名称:stymie-ts,代码行数:45,代码来源:generateEntry.ts
示例4: add
const log = libUtil.log;
const logError = libUtil.logError;
const logInfo = libUtil.logInfo;
const logRaw = libUtil.logRaw;
const logSuccess = libUtil.logSuccess;
const env = process.env;
const keyFile = `${env.STYMIE || env.HOME}/.stymie.d/k`;
const reWhitespace = /\s/g;
export const key: Stymie = {
add(key) {
generateKey(key);
},
edit(key) {
jcrypt(keyFile, null, ['--decrypt'], true)
.then((data: string): void => {
const list: string[] = JSON.parse(data);
const entry = list[key];
let prompts, hasChanged: HasChanged;
if (entry) {
hasChanged = {
changed: false
};
prompts = [{
type: 'input',
name: 'key',
message: 'Edit key:',
default: key,
开发者ID:btoll,项目名称:stymie-ts,代码行数:31,代码来源:key.ts
示例5: openEditor
openEditor(path, () =>
// Re-encrypt once done.
jcrypt(path, null, util.getGPGArgs())
.then(() => logInfo('Re-encrypting and closing the file'))
.catch(logError)
开发者ID:btoll,项目名称:stymie-ts,代码行数:5,代码来源:file.ts
注:本文中的jcrypt类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论