Created
March 11, 2021 14:48
-
-
Save sunaot/260897d63baea3d2c07e06f0e6af7cd8 to your computer and use it in GitHub Desktop.
excalidraw の部屋の URL をつくるときの支援スクリプト
This file contains hidden or 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
require 'digest/sha1' | |
def room_id(name) | |
digest = Digest::SHA1.new | |
digest.update(name) | |
digest.hexdigest.slice(0,20) | |
end | |
def encryption_key(seed) | |
alphabets = ('a'..'z') | |
capital_alphabets = ('A'..'Z') | |
numbers = 0..9 | |
marks = %w( _ - ) | |
(alphabets.to_a + capital_alphabets.to_a + numbers.to_a + marks).shuffle(random: Random.new(seed)).slice(0, 22).join | |
end | |
name = ARGV.shift | |
pass_number = ARGV.shift.to_i | |
puts "https://excalidraw.com/#room=#{room_id(name)},#{encryption_key(pass_number)}" | |
exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment