Last active
December 29, 2015 06:29
-
-
Save cohama/7629492 to your computer and use it in GitHub Desktop.
Vim script でランダム文字列生成
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let s:V = vital#of('r') | |
let s:Xor = s:V.import('Random.Xor128') | |
function! s:randomString(char_kind, length) | |
let rand_str = '' | |
for i in range(a:length) | |
let rand_char = a:char_kind[abs(s:Xor.rand()) % len(a:char_kind)] | |
let rand_str .= rand_char | |
endfor | |
return rand_str | |
endfunction | |
let s:ascii_kinds = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&''()-=^~\|@`[{;+:*}},<.>/?_' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment