Feb 03

My Little Pony Friendship is Magic Guitar Chords

I bought a guitar today. I do not have much knowledge about playing the guitar and I bought it with the intention of learning a new skill and just having a good time with it. I’m hoping to learn to play over the next few months. As will be the case with kids mine thought I am apparently a professional guitar player as soon as they saw it and within a few minutes they were begging me to play “My Little Pony Friendship is Magic” for them. Of course, I didn’t know how, but I told them I’d try to learn it. I found this video on youtube video which is an awesome electric guitar cover of the My Little Pony song. In the comment section someone posted the chord progression so I’m well on my way. Here it is if you’re interested!

The video:
http://www.youtube.com/watch?feature=fvwp&NR=1&v=rApnYmZWnzM

A link to it in case you don’t see it above.

The chords:
(D) My Little Pony,
(A) My Little Pony
(G) Ah, (A) ah, (Bm) ah, (C#) ah
(D) My Little Pony
(Bm) I used to wonder
(A) what friendship could be
(D) My Little Pony
(Bm) Until you all shared its
(A) magic with me
(G) Big adventure
(Bm) Tons of fun A
(A) beautiful heart Faithful and strong
(A) (G) Sharing kindness It’s an
(Bm) easy feat And
(A) magic makes it all complete You have
(D) My Little Pony
(Bm) Do you know you are my
(A) very best friends (G)(A)(Bm)(C#)(D)

Oct 29

10 ways for making money off of free eBooks

Ebooks are one of those things that can really divide people. But for a weird reason. Some people feel that because ebooks can be copied for free that it is somehow not as valuable to have an ebook as it is to have a hardcopy. That somehow people are being cheated when asked to pay the same prices for an ebook as they are are asked to pay for the hard copy version. In my opinion, this is just crazy talk. The value of a book is in the information / entertainment value that it provides… not its format.

So I was reading a question online the other day where someone wanted to know how they could make money off of their eBook. I’ve got atleast 8 thoughts on that so here goes (in no particular order).

1. You could embed affiliate links to other books within the ebook
2. You can offer additional content that supplements the eBook for a fee.
3. Require an email address/newsletter subscription before sending the free eBook, and then try and monetize through the future interactions.
4. Offer physical copies of the book for a fee if readers scoff at the idea of paying for the eBook.
5. Break the eBook up into smaller parts for an email newsletter series, and monetize in the newsletter
6 .Turn the ebook into a mutipage website and populate with Google Ads
7. Sell resale rights, PLR, etc.
8. Write additional eBooks and then use your free ebooks to advertise the pay books.

Basically it all boils down to providing a quality bit of content! If you’ve done that then the actual delivery method of that content can be tweaked until one or more models are found that enable a profit to be made. But in the end, the worst case, is that with the eBook you are able to set yourself up as an expert and to use it to drive more sales in later endeavors. Just make sure your work is quality!

Do you have experience with this type of endeavor? What do you think about these ideas?

Sep 13

Formatting and Final Steps in e-book Publishing

What a busy few weeks it’s been! I got what is pretty close to my final draft done on my ebook and I’ve been working on formatting and getting a book cover designed. Here’s a little about the process.

I’ve decided that step 1 will be to completely self publish. I’ll be publishing on Kindle and on Barnes And Noble because it is free to do so as long as you’re willing to do the work yourself. Since the majority of ebooks are sold through those two outlets I’m okay with temporarily missing out on the possible revenue at Apple / iTunes. I’ll also be publishing via my own website using e-junkie.com as the delivery mechanism. I’ve only been working with e-junkie for a few months, but they make my life so much easier… and it won’t cost me a penny over what I’m already paying to add my book as a product along with my existing products AND that they will deliver to customers after purchase!

My reason for skipping the Apple route is because they require an ISBN and those aren’t cheap. I did find that it would be an option to go through SmashWords and that they will give you a free ISBN when you publish through them. To publish through SmashWords you have to create a “SmashWords Edition” of your ebook (I think you just change the title page to say “Smashwords Edition” and that’s it), so I’ll definitely be doing this after I’ve got my own versions out there. Smashwords also takes a 10% cut so by self publishing to Amazon and B&N I can keep those nickels and quarters for myself and just pay the 10% commission on the places I can’t sell without their help.

After I wrote the initial book I was trying to decide how to get the book converted to the necessary formats. I was going to hire someone via elance, and the bids weren’t too bad (about $100 USD), but since I didn’t know what was involved I was uncomfortable paying just about any cost. I decided instead to go through the Smashwords Style guide to format the manuscript for auto conversion. I can’t say enough about how helpful that guide was. I read it through all the way once and then did the conversion according to the “nuclear option” mentioned. It took me about 1 day to do my 100 or so pages book, and I’m pretty confident that it will go through whatever conversions tools are out there. In the end I think I made the right decision. I saved a little bit a money and learned a lot about what Microsoft Word can do. I didn’t have to let my manuscript out into the world, and I don’t have to worry about someone doing it wrong and then me having to figure out what they did. I recommend you do it yourself when the time comes if you have the time to do it.

Now, for the cover I hired someone via elance. I posted the job, got about 15 bids in 48 hours and then just had to select the best one. I can tell you that in my bid I asked for both the cover and various banner ad sizes. The woman I selected to do the job has been great to get started with and I should have the first concept my hands in the coming days. She priced her bid very reasonably, not too expensive and not so cheap as to make think her work was cheap. I’ll let you know how it turns out and if it turns out really well I’ll post a link to her profile on elance.com to help both you and her out. As it is today I’m debating just getting the book out there without a cover so it will be available for sale. Maybe I’ll create a quick cover with just basic large friendly letters. I’m antsy because it’s a basketball related book and we’re coming up on basketball season. I don’t want to lose sales waiting on a book cover. Thoughts?

I’ve also included a few links below to things I found useful when going through this process.

http://janefriedman.com/2012/02/10/10-questions-epublishing/

How to upload to Kindle Store (pdf)

A writeup about the parts of a book and what goes in each part – a pretty awesome website (writersandeditors.com) with lots of great content for writers

That’s it for this installment. I’ll be sure to post some more once my book is actually out there somewhere. For now, good luck in your own efforts!

Aug 01

HOWTO: Using Paypal buttons with ASP.net the easy way

A couple of years ago I wanted to add a donation button to an ASP.net website. Specifically I wanted a Paypal based donation button. It should have been really easy. Paypal will let you make buttons on their site and they’ll generate the code for you to put onto your own web page. But unfortunately… it’s just not really that easy.  I recently needed to do this again (just today actually) and couldn’t bring myself to use one of the old hacks I had done, and I finally found a super easy solution. I don’t understand why it was so hard to find this information, but I decided to write it up for all to see and use.

The problem is that the code that PayPal generate is html form code. The “action” of the form is a page on their website. The reason that this is a problem is because most people use masterpages within their ASP.net webpages and those masterpages typically have form tags already in them. Since webpages are only supposed to have one “form” per page then adding the PayPal generated form in the content area of a page that is wrapped within a form on the masterpage is just not going to work. What happens is that when the user clicks on the PayPal submit button it just posts back to local website instead of posting to PayPal. Very annoying.

I read about 20 web pages / tutorials today about how one can use PayPal generated buttons within an ASP.net, and I was about to finally give up and do it the old way when it occurred to me that maybe I could control the current page’s masterpage’s form’s action programatically. (By the way that was the most possessives in a row ever!)

So here’s the deal, and it is so easy. Let’s say that the PayPal code generated for you looks like:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
 <input type="hidden" name="cmd" value="_s-xclick">
 <input type="hidden" name="hosted_button_id" value="blablablabla">
 <table>
 <tr><td><input type="hidden" name="on0" value="Subscription Level">Subscription Level</td></tr><tr><td><select name="os0">
 <option value="Pro">Pro $5.00 USD</option>
 <option value="Allstar">Allstar $15.00 USD</option>
 <option value="Superstar">Superstar $25.00 USD</option>
 </select> </td></tr>
 </table>
 <input type="hidden" name="currency_code" value="USD">
 <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
 <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
 </form>

Go ahead and paste the generated code into your page wherever it is you want it to go. You don’t have to jump through any hoops here. Now go to your codebehind and add a couple of lines to the “PageLoad” method for the page in question. Here’s a super simple PageLoad with the two new lines:

protected void Page_Load(object sender, EventArgs e)
 {
 if (!IsPostBack) 
 {  } 
 else  {  } 
 Form.Action = "https://www.paypal.com/cgi-bin/webscr";  
Form.Method = "post"; 
}

That’s it! What we did was we just programmatically set our Masterpage’s form’s action and method to whatever the PayPal form’s action / method was. So, now, when you click on the PayPal button your MasterPage form will still be the one that handles it, but it will handle it the exact same way that the PayPal form would have. Enjoy!

Please let me know how it works for you!

Jul 09

Things to consider when writing (and immediately after writing) an ebook

What are the things to consider when writing (and immediately after writing) an ebook?

Well, you’ve got to price it. How do you determine a correct price though?

You’ve got to proof read. Actually you need someone else to do it! Who can do this for you?

You’ve got to market it. How do you get the conversions up?

You’ve got to make sure that when people want to buy it that your sales system works. What are some good systems for doing this?

All of these items are atleast somewhat discussed in the article linked here. They also have a “most read articles” section that looks like those alone might be worth the read. Enjoy.

http://theadventurouswriter.com/blogwriting/after-writing-ebook-pricing-marketing-landing-pages/

Please share your ideas about any of these topics. I’m very interested to hear from those who have published successfully.

Jul 09

Ebook formatting suggestions from other site

When creating an ebook there are all kinds of questions to ask about how it should be formatted, what sections there ought to be, and more. I’m working on my first ebook which I’ve almost finished writing and I’m starting to wonder how it’s going to “look” when the time comes. I was originally just wondering if ebooks should be double spaced so I took to Google and asked “Should ebooks be double spaced?”. Genius, I know. The first link I got back was very informative and answered a whole lot more questions than just that so I figured I’d post the link so I can get to it later. So here’s the link and a few useful tidbits I got from it. Please please please visit the original page as it is more complete! These are just my notes in case the page ever disappears from the web:

http://workingwritersandbloggers.com/2010/10/07/how-to-format-a-manuscript-for-an-ebook/

In Word, format the paper using the following settings:

  • Page orientation should always be portrait. Go to Page Layout, Orientation, and choose Portrait.
  • Use double spacing. Go to Page Layout, Paragraph, and choose “double” for line spacing.
  • Use one-inch margins all the way around the manuscript. Go to Page Layout, Margins, and choose the “Normal” setting, which assigns one inch evenly around the page. Or, go to Page Layout, Margins, Custom Margins, and choose one inch for the Top, Bottom, Left, and Right settings. Leave the Gutter Setting at zero and Gutter Position at left.
  • Use Times New Roman font, 12.
  • Use a 0.5 space indent for paragraph formatting. When you arrive at a new paragraph, hit “tab” and the cursor will indent to the 0.5 mark. Use this instead of an extra line to indicate a new paragraph.

Cover

If you choose to use a graphic cover for your ebook, it will go on the very first page. This is a personal preference, however, as some authors choose to start their ebook with a typewritten title page instead. The cover image of the ebook might then be used as a graphical selling point on a website, and not used in the ebook itself.

If you are using a cover image, save the file to fit an 8.5 x 11 inch size. Any size inside of this dimension will work. Make sure the cover image is saved to 100 dpi or less to ensure that it does not increase the file size of your ebook. Save the cover image as a JPG or TIFF file.

Header

Place a header at the top of each page of your manuscript except the first (title) page. Your book title, name, and page number should be at the top. Create a separate header for even and odd pages.

Format the even pages first. Go to Insert, then Header. Scroll down through the options until you see Contrast (Even Page). Select it.

This header style is built in with page numbers/text already formatted. Enter your first and last name (or pen name) in the text section. Hit the Escape button to return to your document.

Now, choose the header for the odd pages. Go to Insert, then Header, and scroll down to Contrast (Odd Page). Click on it.

As with the even header box, you’ll see that Word has already formatted the page numbers here. Go to the top text section where it says “Type the company name” and highlight it. Type in the title of your book or manuscript.

Where it says “Type the document title” (below where you now have your book title) you can type your subtitle, or highlight the area and hit “cut” to remove. Please note: if you highlight it and just hit delete, the text “Type the document title” will remain once you return to your document. When you are finished with your header, hit Escape (“Esc”) and you are back into your document.

Notice to the Reader

The next page should be a “notice to the reader.” This page tells the reader they are allowed to download your ebook file but not sell it or pass it along to anyone else. The Notice to the Reader page will have your title once again, this time typed in about 14 point font. The copyright information, which is “Copyright © by AUTHOR NAME” should be typed in 10 point font.

On the next line, type your title in all caps in about 10 point font.

The next lines contain your publishing company information. Type the name of your publishing company and website address. If you have a post office box number for your company, this information can also be included. If the address for your publishing company is your home address, then leave that information off.

Following the publishing company name and address, list the cover art information. This should say “Cover art by NAME.” Fill in the person’s name who created the cover art. If that person is you, use your name. If you do not have a cover image for your ebook, you can skip this.

Next should be the following paragraph:

By purchasing this ebook you are stating that you are fully aware that you will be sent the ebook or download link via email and that this purchase is NOT refundable. Legally, you can save one copy of the purchased ebook to disk for your own personal use. However, it is illegal to distribute your copy to those who did not pay for it. You may not distribute the ebook to other individuals by using email, floppy discs, zip files, burning them to CD/DVD, selling them on any type of auction website, making them available for free public viewing or download on any website, offering them to the general public offline in any way, or any other method currently known or yet to be invented. You may not print copies of your downloaded book and distribute those copies to other persons. Doing any of these things is a violation of international copyright law and would subject you to possible fines or imprisonment. Violators will be prosecuted to the fullest extent of the law.

All rights reserved. Except for use in any review, the reproduction or utilization of this work in whole or in part in any form by any electronic, mechanical or other means, now known or hereafter invented, including xerography, photocopying and recording, or in any information or retrieval system, is forbidden without the prior written permission of both the publisher and copyright owner of this book.

On the next line, list the ISBN if you have one. Not all ebooks will. For example, you can list an ebook on Amazon.com with their Kindle  reader without an ISBN. However, if you plan on selling your ebook on your website or blog, it’s a good idea to have an ISBN.

Accomplishments

The page following the Notice to the Reader generally lists an author’s other works or accomplishments. If you have written other books, then type out “Also by” and follow with the names of the books. If you have created a game, teaching system, or any other accomplishment related to the ebook, then list it briefly on this page. If you don’t have these items, just leave the page blank.

Table of Contents

The next page allows for an optional table of contents. Type the name of each chapter, followed by the page number. If your ebook is short and you don’t have a table of contents, you can leave this section blank.

Text

Now you’re ready to start your text! This is the exciting part of writing. Craft your ebook text using double spacing.

Resources

At the end of your ebook, you may want to include resources to direct the reader to further information. These could be links to sites, books, or any other help information related to your ebook topic.

Including links is a great idea with an ebook, but the Internet changes quickly. It’s always a good idea to put a page on your website or blog that includes updates to the links you have in your ebook. Direct readers to your website for a list of current links. That way you only have to update one location (your website or blog) and you don’t need to re-issue copies of your ebook with corrected links.

Author Page

Following the resources, include an author page. This page should be brief, with a list of your other related accomplishments or writing works. Include a small photo of yourself as well. End the bio with your website, where readers can find out more about you.

ISBN

If you have an ISBN, end your book with its listing. Put the ISBN on the final page, in the bottom right corner.

Ebook Creation

When you are finished with your entire ebook manuscript, save the file as a PDF. This is the standard format for ebooks that are sold off of personal websites or blogs, as well as distributors such as Lightning Source.

May 26

Writing, Creating, Publishing, and Selling Ebooks

I’m going to be trying to finish creating my first ebook and then offer it for sale over the next month or so and this page is my initial “notes” for how to go about it. When I come across some useful concept  I’ll either add a link here or add a page to the new Ebook Publishing HowTo category.

The first resource I have to recommend is a website called smashwords to which you basically upload your manuscript and it converts and then sends it to various publishing sites like Amazon, Barnes and Noble, Apple, and more. The first link describes their service, but at the bottom of the page it has a link to several articles about how to be successful in publishing ebooks. They look like pretty good resources.

http://www.smashwords.com/about/how_to_publish_on_smashwords

The second link is a to a page where you can download their free book about how to format your ebook.

http://www.smashwords.com/books/view/52

I haven’t used the smashwords.com service so I’m only recommending them as a potential option and as a resource to learn from. If I decide to use them as my distributor then I’ll definitely post a review.

Feb 21

Quick notes on my first book scanner

I’ve been working on my first scanner. I decided to build the “new standard scanner”. The step by step guide to building it can be found here, but as it is fresh in my mind I want to throw out a couple of notes.

First, you only have to be pretty accurate in your measurements and cuts. For the most part the tolerance is quite large… which is good for me. 🙂

Second, this is a 90 degree scanner. That is, the book is held open at 90 degrees. Between 100 and 110 degrees is going to be a little better. The thing is that at 90 you are very close to ideal partly because your book bindings won’t get messed up from being opened too far. However, if you make it closer to 100 degrees you will get most of the same   benefit while also removing a small amount of “reflection” where the camera picks up the page across from what it’s shooting. It’s just a suggestion, but I’ll be building my second version to 100 degrees or maybe even up to  110 degrees. What would be awesome is if you angle was adjustable. And now that I think about it that might not be that hard and would be worth looking in to.

Third, do pre-drill holes before you screw them, especially on pieces of wood that you just spent a long time cutting! The screw can split your wood if you’re not careful.

references:

http://www.diybookscanner.org/

http://www.diybookscanner.org/forum/viewtopic.php?f=1&t=333

As a super final last note I have to mention that while writing this post I went to the  main diybookscanner.org page and then clicked on forum. When I did I was  redirected to some other site… I think it  was either an “ru” or an “nu” and had ff in it somewhere, I think. I was unable to reproduce it, and nothing ever loaded on the page,  but it somehow caused me to be logged out of most sites.  I’ve never had any problems visiting the diy site before, but I thought I’d mention it just in case.

 

Feb 05

Hashing library for iOS and how it can be used in conjunction with .Net hashing

I’m working on an iPhone / iPad app that needs to be able to authenticate itself to the server from which it requests data. The users of the app will have an account with the website so they will already have a username / password. There is no SSL functionality, so I needed a way to authenticate over plaintext without giving away the password or even the hash of it.

Let’s talk about what the webserver does in relation to storing the password. It doesn’t actually store the password.  It stores a hashed value where the actual password was combined with a salt (random string of a descent length) and that combined string was hashed using SHA256. The result is stored as the “password” for the user and the salt used to compute the hash is also stored for that user. When the user logs in the password they send (using ssl, so it is encrypted between the user and server) is combined with the stored salt and hashed. If the result is the same as the stored hash then the user is authenticated, otherwise they are not.

Here’s a little helper class written in C# for doing the Hash. It’s server side and .net specific.


#region HashingLogic
public class Hash
 {
 public Hash() { }
public enum HashType : int
 {
 MD5,
 SHA1,
 SHA256,
 SHA512
 }
public static string GetHash(string text, HashType hashType)
 {
 HashAlgorithm _algorithm;
 switch (hashType)
 {
 case HashType.MD5:
 _algorithm = MD5.Create();
 break;
 case HashType.SHA1:
 _algorithm = SHA1.Create();
 break;
 case HashType.SHA256:
 _algorithm = SHA256.Create();
 break;
 case HashType.SHA512:
 _algorithm = SHA512.Create();
 break;
 default:
 throw new ArgumentException("Invalid hash type", "hashType");
 }
byte[] bytes = Encoding.Unicode.GetBytes(text);
 byte[] hash = _algorithm.ComputeHash(bytes);
string hashString = string.Empty;
 foreach (byte x in hash)
 {
 hashString += String.Format("{0:x2}", x);
 }
 return hashString;
 }
public static bool CheckHash(string original, string hashString, HashType hashType)
 {
 string originalHash = GetHash(original, hashType);
 return (originalHash == hashString);
 }
}
 #endregion

And here’s the webserver checking the Hash. It should be pretty easy to see how to store it as well when a user sets their password in the first place.

 // ran a query that returned the hashed password and salt for the user in question
 // note: password is the value sent by the user trying to log in
 string the_hashed_password = dt.Rows[0]["vcHashedPass"].ToString().Trim();
 string the_salt = dt.Rows[0]["vcPassSalt"].ToString().Trim();
 string the_salted_password = password.Trim() + the_salt;
 string hashedvalue = Hash.GetHash(the_salted_password, Hash.HashType.SHA256);
     if (hashedvalue == the_hashed_password)
         loginSuccessful = true;

 

Now that we have the background, I can talk about what really screwed with me. I was trying to implement part of this on the iOS side. , but I was getting a different value back for my hash. I used a Hash library for iOS from this site. It was easy to use. Just copy the files to your project and import the .h into whatever file you need to do hashing.  Before hashing an NSString you must first convert it to an NSData. But this conversion requires you to specify the encoding. To use it in conjunction with the .Net helper class above you have to choose the right encoding or it will has to the wrong value. Code first, then discussion.

NSString *usernameex = [keychainwrapper objectForKey:(id)kSecAttrAccount];
 NSString *passwordex = [keychainwrapper objectForKey:(id)kSecValueData];
 // I'm hardcoding the salt for this example, now we need to talk to the server  to see if it will let us log in with it
NSString *retrievedSalt = [NSString stringWithFormat:@"b3b5c979-3438-4f56-aa1a-1d85bda78b7e"];
 NSString *saltedpassword =  [NSString stringWithFormat:@"%@%@", passwordex, retrievedSalt];
// Webserver thinks that hashed(password+salt)  =
 // 14083e601f136a42bb17f37a6dedfd03c1f53f2c93f2cc886de5b44ed4a452c1 -- looking for
// but this library was returning various results... here's one
 // ed87d50a50937361f17f9b3c32c6db04e6b7779e5f3c42dfa20e44cac7bf112e -- getting
 // there are lots of example of how the "encoding" can be done and what the hashed value that results is
 // I included them in this sample code because I had to try a ton to finally find the one that matched the .net
HashValue *hashvalue;
//NSUTF16StringEncoding 762ce0d893b64032f11562e4ee0be3f4ed08ca6b801ab892d319af3942ca788c
 NSData* datasaltedpassword0a=[saltedpassword dataUsingEncoding:NSUTF16StringEncoding];
 hashvalue = [HashValue sha256HashWithData:datasaltedpassword0a];
 ASLog(@"hashedvalue0a - %@", hashvalue.description); // password - whatever you entered
NSData* datasaltedpassword0b=[saltedpassword dataUsingEncoding:NSUTF16BigEndianStringEncoding];
hashvalue = [HashValue sha256HashWithData:datasaltedpassword0b];
ASLog(@"hashedvalue0b - %@", hashvalue.description); // password - whatever you entered
NSData* datasaltedpassword0c=[saltedpassword dataUsingEncoding:NSUTF16LittleEndianStringEncoding];
hashvalue = [HashValue sha256HashWithData:datasaltedpassword0c];
ASLog(@"hashedvalue0c - %@", hashvalue.description); // password - whatever you entered
NSData* datasaltedpassword0d=[saltedpassword dataUsingEncoding:NSUTF32StringEncoding];
hashvalue = [HashValue sha256HashWithData:datasaltedpassword0d];
ASLog(@"hashedvalue0d - %@", hashvalue.description); // password - whatever you entered
NSData* datasaltedpassword0e=[saltedpassword dataUsingEncoding:NSUTF32BigEndianStringEncoding];
hashvalue = [HashValue sha256HashWithData:datasaltedpassword0e];
ASLog(@"hashedvalue0e - %@", hashvalue.description); // password - whatever you entered
NSData* datasaltedpassword0f=[saltedpassword dataUsingEncoding:NSUTF32LittleEndianStringEncoding];
hashvalue = [HashValue sha256HashWithData:datasaltedpassword0f];
ASLog(@"hashedvalue0f - %@", hashvalue.description); // password - whatever you entered
//NSUTF8StringEncoding
NSData* datasaltedpassword1=[saltedpassword dataUsingEncoding:NSUTF8StringEncoding];
hashvalue = [HashValue sha256HashWithData:datasaltedpassword1];
ASLog(@"hashedvalue1 - %@", hashvalue.description); // password - whatever you entered
//[NSString defaultCStringEncoding]
NSData* datasaltedpassword2=[saltedpassword dataUsingEncoding:[NSString defaultCStringEncoding]];
hashvalue = [HashValue sha256HashWithData:datasaltedpassword2];
ASLog(@"hashedvalue2 - %@", hashvalue.description); // password - whatever you entered
//NSUnicodeStringEncoding allowLossyConversion:NO
NSData* datasaltedpassword3=[saltedpassword dataUsingEncoding:NSUnicodeStringEncoding allowLossyConversion:NO];
hashvalue = [HashValue sha256HashWithData:datasaltedpassword3];
ASLog(@"hashedvalue3 - %@", hashvalue.description); // password - whatever you entered
//NSWindowsCP1252StringEncoding
NSData* datasaltedpassword4=[saltedpassword dataUsingEncoding:NSWindowsCP1252StringEncoding];
hashvalue = [HashValue sha256HashWithData:datasaltedpassword4];
ASLog(@"hashedvalue4 - %@", hashvalue.description); // password - whatever you entered
//NSMacOSRomanStringEncoding
NSData* datasaltedpassword5=[saltedpassword dataUsingEncoding:NSMacOSRomanStringEncoding];
hashvalue = [HashValue sha256HashWithData:datasaltedpassword5];
ASLog(@"hashedvalue5 - %@", hashvalue.description); // password - whatever you entered
ASLog(@"targetvalue - 14083e601f136a42bb17f37a6dedfd03c1f53f2c93f2cc886de5b44ed4a452c1", hashvalue.description); // password - whatever you entered

And the output:

2012-02-05 16:13:38.077 [11082:560f] LoginViewController.m:121 -[LoginViewController workOfDoLogin] password – ocelot

2012-02-05 16:13:38.078 [11082:560f] LoginViewController.m:140 -[LoginViewController workOfDoLogin] salt – b3b5c979-3438-4f56-aa1a-1d85bda78b7e

2012-02-05 16:13:38.078 [11082:560f] LoginViewController.m:144 -[LoginViewController workOfDoLogin] saltedpassword – ocelotb3b5c979-3438-4f56-aa1a-1d85bda78b7e

2012-02-05 16:13:38.080 [11082:560f] LoginViewController.m:152 -[LoginViewController workOfDoLogin] hashedvalue0a – 762ce0d893b64032f11562e4ee0be3f4ed08ca6b801ab892d319af3942ca788c

2012-02-05 16:13:38.080 [11082:560f] LoginViewController.m:156 -[LoginViewController workOfDoLogin] hashedvalue0b – df7e828a1df0664ff42756960ab7f63e83f0504437c59286e217df32147d8815

2012-02-05 16:13:38.081 [11082:560f] LoginViewController.m:160 -[LoginViewController workOfDoLogin] hashedvalue0c – 14083e601f136a42bb17f37a6dedfd03c1f53f2c93f2cc886de5b44ed4a452c1

2012-02-05 16:13:38.082 [11082:560f] LoginViewController.m:164 -[LoginViewController workOfDoLogin] hashedvalue0d – 4276b8d7ff791492f537379bf7353095d8ce40c717f15dc242f2847b376b88de

2012-02-05 16:13:38.083 [11082:560f] LoginViewController.m:168 -[LoginViewController workOfDoLogin] hashedvalue0e – 45838174fdf6cb95b7ed6bdbd7409f065c75f12958e58ae84ec5d28235b6cf0e

2012-02-05 16:13:38.083 [11082:560f] LoginViewController.m:172 -[LoginViewController workOfDoLogin] hashedvalue0f – 492adfab98090cf9319684aa707d368a2689495480a59ffd7a9b2a514ea9362d

2012-02-05 16:13:38.084 [11082:560f] LoginViewController.m:178 -[LoginViewController workOfDoLogin] hashedvalue1 – ed87d50a50937361f17f9b3c32c6db04e6b7779e5f3c42dfa20e44cac7bf112e

2012-02-05 16:13:38.085 [11082:560f] LoginViewController.m:183 -[LoginViewController workOfDoLogin] hashedvalue2 – ed87d50a50937361f17f9b3c32c6db04e6b7779e5f3c42dfa20e44cac7bf112e

2012-02-05 16:13:38.086 [11082:560f] LoginViewController.m:188 -[LoginViewController workOfDoLogin] hashedvalue3 – 762ce0d893b64032f11562e4ee0be3f4ed08ca6b801ab892d319af3942ca788c

2012-02-05 16:13:38.086 [11082:560f] LoginViewController.m:193 -[LoginViewController workOfDoLogin] hashedvalue4 – ed87d50a50937361f17f9b3c32c6db04e6b7779e5f3c42dfa20e44cac7bf112e

2012-02-05 16:13:38.087 [11082:560f] LoginViewController.m:198 -[LoginViewController workOfDoLogin] hashedvalue5 – ed87d50a50937361f17f9b3c32c6db04e6b7779e5f3c42dfa20e44cac7bf112e

2012-02-05 16:13:38.088 [11082:560f] LoginViewController.m:201 -[LoginViewController workOfDoLogin] targetvalue – 14083e601f136a42bb17f37a6dedfd03c1f53f2c93f2cc886de5b44ed4a452c1

 

The right Encoding to use on the iOS side was “NSUTF16LittleEndianStringEncoding”. I had to do all of those tests to finally find which one matched the values being produced on the web side (.Net)… so just keep in mind that if your getting two different hashes then you might need to use a different Encoding during the conversion from String to Byte / Data in order to make them sync up.

Feb 04

Hiding the Keyboard when touching background

If you are working on an iOS app and have the need for the user the enter input then you usually use a textfield or textview. I was working on a login screen and had a very annoying experience where the keyboard wouldn’t go away after I had finished entering my text. What was especially annoying was that I had encountered it before and had simply forgotten how to resolve it. So I’m writing this up for myself or anyone else who needs the info.

All you have to do is make sure that your view has ‘User Interaction Enabled’ checked under the ‘Attributes Inspector’. Then add the following block of code to your view’s implementation. You can see that I have two textFields called txtUsername and txtPassword. You’ll want to change them to match the names of all the text fields on your form (you don’t know which one is actually the first responder at the time, but from what I’ve read it doesn’t hurt to resign if you are not it anyway). So that’s it.

– (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

UITouch * touch = [touches anyObject];

if(touch.phase == UITouchPhaseBegan) {

[self.txtPassword resignFirstResponder];

[self.txtUserName resignFirstResponder];

}

}

Here’s another place that discusses it in a bit more detail.

I’ll also mention that some people use a hidden button the size of the view. Then they tie that button to a “hideKeyboard” method. That solution is also discussed in that thread. I found a better explanation of it a Sams Publishing teach yourself Iphone Development book, but the discussion on that thread will suffice. For my own reference it is on page 179-182. It also discusses how to release the keyboard when the “Done” button is pressed. You will probably want to implement BOTH.