Advertisement
Guest User

asdfasdf

a guest
Feb 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. <html>
  2.  
  3. Input String: <input type="text" id="input"/><br />
  4. Grab every # character: <input type="text" id="num"/> <br/>
  5. <input type="button" onclick="doChar()" value="Grab Characters"/> <br />
  6.  
  7. Raw Result: <br />
  8. <div id="result"> Results Here </div>
  9. ROT13 Result: <br />
  10. <div id="resultrot13"> Results Here </div>
  11.  
  12.  
  13. </html>
  14.  
  15.  
  16. <script>
  17.  
  18. function doChar(){
  19. var input = document.getElementById("input").value;
  20. var num = document.getElementById("num").value;
  21. var result = "";
  22.  
  23. console.log("Num is " + num);
  24.  
  25. for (var i = 0; i < input.length ; i++){
  26. if (i % num == 0){
  27. result += input[i];
  28. console.log("Added " + input[i]);
  29. }
  30. }
  31.  
  32. document.getElementById("result").innerHTML = result;
  33. result = rot13rot5Encode(result);
  34. document.getElementById("resultrot13").innerHTML = result;
  35. }
  36.  
  37.  
  38.  
  39.  
  40. // Simple ROT13+ROT5 cipher (Javascript implementation)
  41. // Copyright StatiX Industries 2013 (MIT License)
  42.  
  43. //This is the alphabet array
  44. var alphaBetString = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z";
  45. var alphaBetTable = alphaBetString.split(" ");
  46.  
  47. //This is the lookup table/array for the ROT13 characters
  48. var rot13String = "N O P Q R S T U V W X Y Z A B C D E F G H I J K L M n o p q r s t u v w x y z a b c d e f g h i j k l m";
  49. var rot13Table = rot13String.split(" ");
  50.  
  51. //This is for numbers. Numbers will be passed thru ROT5
  52. var numberString = "1 2 3 4 5 6 7 8 9 0";
  53. var numberTable = numberString.split(" ");
  54.  
  55. //This is the lookup table of ROT5
  56. var rot5String = "6 7 8 9 0 1 2 3 4 5";
  57. var rot5Table = rot5String.split(" ");
  58.  
  59. //Here's the table for symbols. Symbols will remain the same
  60. var symbolString = "~ ` ! @ # $ % ^ & * ( ) _ + - = { } [ ] \\ | ; \' : \" < > ? , . /";
  61. var symbolTable = symbolString.split(" ");
  62.  
  63. //Main function
  64. var rot13rot5Encode = function(input) {
  65. var output = "";
  66. for (var i=0; i<input.length; i++) { //This is checking for spaces and if yes, add a space to the output
  67. for (var y=0; y<numberTable.length; y++) { //This is the ROT5 cipher for numbers
  68. if (input[i]==numberTable[y]) {
  69. output+=rot5Table[y];
  70. }
  71. }
  72. for (var x=0; x<alphaBetTable.length; x++) { //This is the ROT13 cipher for letters
  73. if (input[i]==alphaBetTable[x]) {
  74. output+=rot13Table[x];
  75. }
  76. }
  77. for (var w=0; w<symbolTable.length; w++) {
  78. if (input[i]==symbolTable[w]) {
  79. output+=symbolTable[w];
  80. }
  81. }
  82. if (input[i]==" ") {
  83. output+=" ";
  84. }
  85. }
  86. return output; //Ultimately, return the output
  87. };
  88.  
  89. //If you want to run the cipher, uncomment the following lines and change userInput to your desired input
  90. //var userInput = "Developed by Pan Ziyue (@sammy0025) in StatiX Industries.";
  91. //console.log(rot13rot5Encode(userInput));
  92.  
  93. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement