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
#!/bin/ruby | |
require 'json' | |
require 'stringio' | |
#class here | |
class MineBoard | |
attr_accessor :height, :width, :num_mines, :board | |
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
<div class="input-container"> | |
<%= f.password_field :password, placeholder: "Password", tabindex: "2", required: "required", data: { encrypt: true } %> | |
</div> | |
<div class="hidden" id="public_key" data-value= "<%= sanitize @public_key %>"></div> |
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
$(document).ready(function(){ | |
$('form').submit(function( event ) { | |
var encrypt = new JSEncrypt(); | |
$('[data-encrypt]').each(function(){ | |
var unencrypted = $(this); | |
encrypt.setKey($('#public_key').attr('data-value')); | |
var encrypted = encrypt.encrypt(unencrypted.val()); | |
if(encrypted) { | |
unencrypted.val(encrypted); | |
} |
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
class Users::SessionsController < Devise::SessionsController | |
include SessionsHelper | |
before_filter :generate_rsa_key, only: [:new] | |
prepend_before_filter -> { authenticate_encryptor([:password]) }, only: [:create] | |
def create | |
# your own code | |
super | |
end |
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
require 'rsa_encryptor' | |
# Module SessionsHelper provides public key encryption/decryption for password | |
# | |
# @author Peiyush13 <[email protected]> | |
# | |
module SessionsHelper | |
# initializes public key used for password encryption | |
# | |
def generate_rsa_key |
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
# Class RsaEncryptor provides Public Encryption/Decryption for the data | |
# | |
# @author Peiyush13 <[email protected]> | |
# | |
class RsaEncryptor | |
attr_reader :rsa_key, :public_key | |
def initialize | |
@rsa_key = OpenSSL::PKey::RSA.generate(1024) | |
@public_key = @rsa_key.public_key.to_s |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="CompilerConfiguration"> | |
<resourceExtensions /> | |
<wildcardResourcePatterns> | |
<entry name="!?*.java" /> | |
<entry name="!?*.form" /> | |
<entry name="!?*.class" /> | |
<entry name="!?*.groovy" /> | |
<entry name="!?*.scala" /> |