Advertisement
Guest User

jebac unie leszno

a guest
Nov 15th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.49 KB | None | 0 0
  1. <form id="cezar">
  2. informacja: <input type="text"><br>
  3. przesuniecie: <input type="number"><br>
  4. <input type="button" value="szyfruj" id="s" onclick="c(this)"><input type="button" id="ds" value="deszyfruj" onclick="c(this)">
  5. </form>
  6. <p id="cw"></p>
  7.  
  8.  
  9. <form id="asym">
  10. informacja: <input type="number"><br>
  11. klucz: <input type="number"><br>
  12. <input type="button" value="szyfruj" id="s" onclick="d(this)"><input type="button" id="ds" value="deszyfruj" onclick="d(this)">
  13. </form>
  14. <p id="sw"></p>
  15. <script>
  16.  
  17. function cezar(info, p){
  18.     info = info.toLowerCase()
  19.     let out = "", tmp
  20.    
  21.     for(let i = 0; i<info.length; i++){
  22.        tmp = info[i].charCodeAt()+parseInt(p)
  23.        console.log(tmp)
  24.        if(tmp>122){
  25.             tmp = tmp-26
  26.         } else if(tmp<97){
  27.            tmp = tmp+26
  28.        }
  29.        
  30.        out += String.fromCharCode(tmp)
  31.    }
  32.    return out
  33. }
  34. function c(b){
  35.    let a = document.getElementById("cezar").children
  36.    let info = a[0].value, p = a[2].value, cw = document.getElementById("cw")
  37.    
  38.    if (b.id == "s"){
  39.        cw.innerHTML = cezar(info, p)
  40.    } else if (b.id == "ds"){
  41.        cw.innerHTML = cezar(info, p*-1)
  42.    }
  43. }
  44.  
  45. function d(b){
  46.    let a = document.getElementById("asym").children
  47.    let info = a[0].value, p = a[2].value, sw = document.getElementById("sw")
  48.    
  49.    if (b.id == "s"){
  50.        sw.innerHTML = info*7*p //publiczny
  51.    } else if (b.id == "ds"){
  52.        sw.innerHTML = info/p //prywatny
  53.    }
  54. }
  55. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement