Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <p class="about"><strong>Passwordify!</strong>A tiny password generator written in javascript. It's not secure enough to use as an encryption hash, but it's good for generationg secure passwords from easy-to-remember words. If you can figure out the pattern, you should be able to generate your passwords in your head! It's not impossible to figure out!</p>
<div class="container">
  <form id="passwordify-form">
    <input id="password" type="text" name="password" placeholder="Type word to convert here..."></input>
  	<input id="submit-button" type="submit" value="Passwordify!"></input>
	</form>	
</div>	
<div id="output"></div>

              
            
!

CSS

              
                * {
    background-color: #888;
    box-sizing: border-box; 
    font-family: Helvetica Arial sans-serif;
    font-size: .9em;
}
.container {
    width: 250px;
    height: 100px;
    margin: 20px auto;
    padding: 0;
    background-color: #333;
    border: 1px solid black;
    border-radius: 5px;
    box-shadow: 1px 1px 2px #666;
}

#output {
    display: none;
    width: 250px;
    padding: 50px;    
    background-color: #EEEEEE;
    box-shadow: 1px 1px 2px #666;
    color: black;
    text-align: center;
    border: 1px solid #DDDDDD;
    border-radius: 5px;
    margin: 50px auto;
    font-weight: bold;
}
#passwordify-form {
    position: relative;
    width: 210px;
    height: 80px;
    padding: 0;
    margin: 10px 20px;
    background-color: #555;
    border: solid 1px #222;
    border-radius: 5px;
    box-shadow: 0 0 2px #444 inset;
}
#submit-button {
    position: absolute;
    background-color: #333;
    border: none;
    border-bottom: 1px solid black;
    border-right: 1px solid black;
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
    padding: 10px;
    bottom: -40px;
    right: -20px;
    color: white;
    box-shadow: 1px 1px 2px #666;
    font-weight: bold;
}
#submit-button:hover {
    text-shadow: 0 0 5px #FFF; 
}
#password {
    width: 200px;
    padding: 3px;
    margin: 27px 4px;
    border-radius: 3px;
    border: solid 1px #444;
    background-color: #FFF;
}
.about {
    background: #FFF;
    width: 250px;
    margin: 20px auto;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 1px 1px 4px #333 inset;
    font-family: Georgia;
    font-size: .8em;
    z-index: -1;
}
.about strong {
    background: #FFF;
    display: block;
    margin-bottom: 10px;
    font-size: 1.2em;
}
              
            
!

JS

              
                    /*********************** PASSWORDIFIER CLASS DEFINITIONS **********************/

    function PassWordifier() {
        /* Array of different types of conversion methods to be accessed by
           passWordify method */
           
        var conversions = [convert1, convert2, convert3, convert4];

    /* PRIVATE METHODS */
    
        /* Returns lowercase version of char */
        function convert1(char) {
            return char.toLowerCase();
        }
    
        /* Returns char converted into its index in the alphabet, with second number,
           (if there is one) converted to its corresponding symbol on the keyboard. */
        function convert2(char) {
            var index = char.toAlphabetIndex();
            /* If index is 2 numbers, convert second to symbol, leave first. If only 1,
               just return first number */     
            if(index.length === 2) {
                return index.charAt(0) + index.charAt(1).numToSymbol();
            } else if (index.length === 1) {
                return index;
            }
        }

        /* Returns uppercase version of char */
        function convert3(char) {
            return char.toUpperCase();
        }

        /* Same as convert2, except first number is symbol, second is number */
        function convert4(char) {
            var index = char.toAlphabetIndex();
            /* If index is 2 numbers, convert first to symbol, leave second. If only 1,
               just return first as symbol */     
            if(index.length === 2) {
                return index.charAt(0).numToSymbol() + index.charAt(1);
            } else if (index.length === 1) {
                return index.numToSymbol();
            }        
        }
        
        /* PUBLIC METHODS */
        
        this.passWordify = function(str) {
            var arr = str.stripNonAlphabetic().split("");
            return arr.doForEach(conversions).join("");
        };
    }

    /***************** JAVASCRIPT CORE FUNCTION EXTENSIONS ********************/


    /* Returns the alphabet index ( a => 1, b => 2, c => 3, etc)
       of the input letter as a string */
    
    String.prototype.toAlphabetIndex = function() {
        /* If this is more than one letter, can't do it. I might fix this later.
           With RECURSION! */
        if(this.length > 1) {
            console.log("toAlphabetIndex can only be called on strings of length 0");
            return;
        } else {
            var alphabet = "abcdefghijklmnopqrstuvwxyz";
            return (alphabet.indexOf(this.toLowerCase()) + 1).toString();
        }
    };
    
    String.prototype.stripNonAlphabetic = function() {
        return this.replace(/[^a-zA-Z]/g, "");
    };
    
    /* Converts number string to corresponding number on keyboard! */
    String.prototype.numToSymbol = function() {
        /* Again, only works on strings of length 1 for now! */
        if(this.length > 1) {
            console.log("numToSymbol can only be called on strings of length 1");
            return;
        }  else {
            switch (parseInt(this, 10)) {
                case 0:
                    return ")";
                case 1:
                    return "!";
                case 2:
                    return "@";
                case 3:
                    return "#";
                case 4:
                    return "$";
                case 5:
                    return "%";
                case 6:
                    return "^";
                case 7:
                    return "&";
                case 8:
                    return "*";
                case 9:
                    return "(";
            }
        }
    };
    
    /* Returns array modified by the passed in function
       funcs is an array of functions to cycle through on each iteration */
    
    Array.prototype.doForEach = function(funcs) {
        var arrLength = this.length;
        var numFuncs = funcs.length;
        var element;
        for(var i = 0; i < arrLength; i++) {
            this[i] = funcs[i % numFuncs](this[i]);
        }
        return this;
    };
    
    
    /*************************** JQUERY EVENT HANDLING ***********************/
    
$(document).ready( function() {
    var myPassWordifier = new PassWordifier();
    $("#submit-button").click( function(e) {
        e.preventDefault();
        var strFromForm = $('#password').val();
        var computed = myPassWordifier.passWordify(strFromForm);
        var $output = $('#output');
        $output.text(computed);
        $output.show('fast');
        $('#password').val("");
    });
});
              
            
!
999px

Console