Removed obsolte code

Updated documentation to correct style
This commit is contained in:
michael starke
2014-02-22 11:55:44 +01:00
parent ae38cdce32
commit a2b8a15e46
2 changed files with 32 additions and 30 deletions

View File

@@ -9,41 +9,55 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
typedef NS_OPTIONS(NSUInteger, MPPasswordCharacterFlags) { typedef NS_OPTIONS(NSUInteger, MPPasswordCharacterFlags) {
MPPasswordCharactersUpperCase = (1<<0), // NSCharacterset lowerCaseCharacterSet MPPasswordCharactersUpperCase = (1<<0),
MPPasswordCharactersLowerCase = (1<<1), // NSCharacterSet upperCaseCharacterSet MPPasswordCharactersLowerCase = (1<<1),
MPPasswordCharactersNumbers = (1<<2), // NSCharacterSet numberCharacterSet MPPasswordCharactersNumbers = (1<<2),
MPPasswordCharactersSymbols = (1<<3), // NSCharacterSet symbolCharacterSet MPPasswordCharactersSymbols = (1<<3),
MPPasswordCharactersAll = MPPasswordCharactersUpperCase | MPPasswordCharactersLowerCase | MPPasswordCharactersNumbers | MPPasswordCharactersSymbols MPPasswordCharactersAll = MPPasswordCharactersUpperCase | MPPasswordCharactersLowerCase | MPPasswordCharactersNumbers | MPPasswordCharactersSymbols
}; };
@interface NSString (MPPasswordCreation) @interface NSString (MPPasswordCreation)
/** /**
@param array with allowed NSChractersSets for creation * Creates a Password using the supplied password character set with the given lenght
@param lenght lenght of the password to create *
@returns a new password with the allowed charaters an the requests lenght * @param allowedCharacters Characters allowed for the password
*/ * @param theLength lenght of the password to be created
*
* @return new password with only the allowed characters.
*/
+ (NSString *)passwordWithCharactersets:(MPPasswordCharacterFlags)allowedCharacters length:(NSUInteger)theLength; + (NSString *)passwordWithCharactersets:(MPPasswordCharacterFlags)allowedCharacters length:(NSUInteger)theLength;
/** /**
@param Source string of allowed characters * Creats a password based on the supplied string
@param lenght Lenght of the password to create *
@return a new password with the given length and allowed characters * @param source String containing the allowed characters
* @param length Lenght for the password to be chreated
*
* @return Password consisint only of allowed characters
*/ */
+ (NSString *)passwordFromString:(NSString *)source length:(NSUInteger)length; + (NSString *)passwordFromString:(NSString *)source length:(NSUInteger)length;
/** /**
@param Length of the password *
@returns a password containing only the characters in the string * Creates a random password with only the characters of the receiver
*
* @param length Length of the password to be created
*
* @return Password containing only the charactesr in receiver
*/ */
- (NSString *)passwordWithLength:(NSUInteger)length; - (NSString *)passwordWithLength:(NSUInteger)length;
/** /**
@returns a random Character from the String * @return returns a random character from the string
*/ */
- (NSString *)randomCharacter; - (NSString *)randomCharacter;
/** /**
@param allowedCharacters Characters that where allowed for the cration of the password * Calculates the entropy of the receiver based on the allowed characers. The caluclation consideres the characters chosen randomly.
@returns entrpy in bits taking into account, the creation was purely random. Do not use this to estimate user generated passswords * If the password supplied was not created randomly based on the full character set, the calulated entropy is NOT correct.
* Do NOT use this method to estrimate unknown passwords
*
* @param allowedCharacters set of allowed Characters
* @param customCharacters alternative string of unique allowed charactes (String is not stripped of duplicates!)
*
* @return entropy of the receiver as bits
*/ */
- (CGFloat)entropyWhithPossibleCharacterSet:(MPPasswordCharacterFlags)allowedCharacters orCustomCharacters:(NSString *)customCharacters; - (CGFloat)entropyWhithPossibleCharacterSet:(MPPasswordCharacterFlags)allowedCharacters orCustomCharacters:(NSString *)customCharacters;

View File

@@ -30,18 +30,6 @@ static NSString *allowedCharactersString(MPPasswordCharacterFlags flags) {
return characterString; return characterString;
} }
@implementation NSString (MPPasswordCreationTools)
+ (NSDictionary *)_createPasswordSet:(MPPasswordCharacterFlags)flags {
return @{};
}
- (NSDictionary *)_createPasswordSet:(MPPasswordCharacterFlags)flags {
return [NSString _createPasswordSet:flags];
}
@end
@implementation NSString (MPPasswordCreation) @implementation NSString (MPPasswordCreation)
+ (NSString *)passwordFromString:(NSString *)source length:(NSUInteger)length { + (NSString *)passwordFromString:(NSString *)source length:(NSUInteger)length {